.net中用到的一些方法

//文件操作
string fullDirPath = Utils.GetMapPath(string.Format("/aspx/{0}/", buildPath)); DirectoryInfo dirFile = new DirectoryInfo(fullDirPath); if (Directory.Exists(fullDirPath)) { foreach (FileInfo file in dirFile.GetFiles()) { //检查文件 Model.url_rewrite modelt = ls.Find(p => p.page.ToLower() == file.Name.ToLower()); if (modelt == null) { if (file.Exists) file.Delete(); } } }
List Find方法
ls.Find(p => p.page.ToLower() == file.Name.ToLower());
//使用数组分割时
string[] names = name.Split(new char[] { '|' });

Directory.GetFiles(dirPath)

//判断文件是否存在
FileArrayIsExist(pic_file,filePath)

原文地址:https://www.cnblogs.com/gexx/p/4615239.html