随笔分类 -  c#文件操作

递归获取文件夹下特定文件
摘要:public void ReadFilePath(string path) { string[] dirs = Directory.GetFileSystemEntries(path);//获取文件目录和文件名 for (int i = 0; i<dirs.Length; i++) { if (Di 阅读全文

posted @ 2019-06-09 16:43 mol1995 阅读(157) 评论(0) 推荐(0)

获取文件夹总大小方法2_获取cmd命令结果,效率最高
摘要:public static long GetDirectorySize(string path) { long res = 0; System.Diagnostics.Process p = new System.Diagnostics.Process(); p.StartInfo.FileName 阅读全文

posted @ 2019-03-02 14:52 mol1995 阅读(722) 评论(0) 推荐(0)

获取文件夹总大小方法1_递归,效率极低
摘要:public static long GetDirectoryLength(string dirPath) { //判断给定的路径是否存在,如果不存在则退出 if (!Directory.Exists(dirPath)) return 0; long len = 0; //定义一个Directory 阅读全文

posted @ 2019-03-02 14:32 mol1995 阅读(218) 评论(0) 推荐(0)

利用itextsharp.dll读取pdf文件
摘要:首先引用itextsharp.dll PdfReader pdfRead = new PdfReader(path); StringBuilder NavDataStr = new StringBuilder(); //数据总页数 int pageNums = pdfRead.NumberOfPag 阅读全文

posted @ 2017-04-08 14:50 mol1995 阅读(343) 评论(0) 推荐(0)

使用AxInterop.AcroPDFLib打开pdf
摘要:首先添加两个dll到引用中 AxInterop.AcroPDFLib.dll Interop.AcroPDFLib.dll 使用前,一定要初始化。下面摘自网上,没有测试过 AxAcroPDFLib.AxAcroPDF acroPDF = new AxAcroPDFLib.AxAcroPDF(); ( 阅读全文

posted @ 2016-11-17 21:59 mol1995 阅读(2863) 评论(0) 推荐(0)

C#获取路径总结
摘要:Application.StartupPath : 获取当前应用程序所在目录的路径,最后不包含“\”; 桌面路径:Environment.GetFolderPath(Environment.SpecialFolder.Desktop) 一、获取当前文件的路径 1. System.Diagnostic 阅读全文

posted @ 2016-11-05 20:48 mol1995 阅读(207) 评论(0) 推荐(0)

2013-1-1遍历文件夹,改名文件
摘要:DirectoryInfo Dir=new DirectoryInfo("D:\\Call of Duty 2\\main\\iwd\\"); //*1 int cnt=0; foreach(FileInfo f in Dir.GetFiles("*.iwd")) { string cc = f.N 阅读全文

posted @ 2016-10-15 19:03 mol1995 阅读(208) 评论(0) 推荐(0)

2016.10.8 文件读取和两种模式写入
摘要:插入文件补充:2016.11.29 1、StreamWriter file = new StreamWriter(path); //直接只跟一个参数也表示替换模式,默认ANSI编码 2、 file.Write(cont) 和 file.WriteLine(cont); 相比后者会在末尾增加一空行 3 阅读全文

posted @ 2016-10-15 18:18 mol1995 阅读(154) 评论(0) 推荐(0)

2016.2.17文件夹选择框及文件选择框
摘要:string fpth = ""; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "请选择走向文件"; openFileDialog.Filter = "文本文件|*.txt"; openFi 阅读全文

posted @ 2016-10-15 17:52 mol1995 阅读(401) 评论(0) 推荐(0)

导航