随笔分类 - IO操作
摘要:一、文件操作1、File类的常用静态方法:void AppendAllText(string path, string contents),将文本contents附加到文件path中bool Exists(string path)判断文件path是否存在string[] ReadAllLines(string path) 读取文本文件到字符串数组中string ReadAllText(string path) 读取文本文件到字符串中void WriteAllText(string path, string contents)将文本contents保存到文件path中,会覆盖旧内容。WriteA
阅读全文
摘要:#region /// /// 写日志文件,保存到指定的文件 /// /// 日志内容 /// 保存到文件 public static void WriterLog(string log, string fileName) { try { // System.Windows.Forms.MessageBox.Show(log); string logPath = System...
阅读全文
摘要:1、// 判断该路径是文件还是文件夹,如果是文件夹if (File.GetAttributes(path).CompareTo(FileAttributes.Directory) == 0){ //DirectoryInfo dinfo = new DirectoryInfo(path); //dinfo.Delete(true); // 直接删除的方式,不会删除到回收站 Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory(path, Microsoft.VisualBasic.FileIO.UIOption.A...
阅读全文

浙公网安备 33010602011771号