- 沒有新回應!
2009-05-12 21:46 刪除某一目錄的某一檔案
刪除某一目錄的某一檔案
---------------------------------------------------------
using System.IO;
protected void Page_Load(object sender, EventArgs e)
{
DirectoryInfo dirinfo = new DirectoryInfo(MapPath("~") + "ExportMapImg");
FileInfo[] sortList = dirinfo.GetFiles();
string fName = "XX.txt";
foreach (FileInfo item in sortList)
{
string ExistFile = item.FullName;
Response.Write(ExistFile + "<br>");
if(ExistFile.IndexOf(fName, 0)!=-1){
Response.Write(ExistFile + " *****delete!! <br>");
System.IO.File.Delete(ExistFile);
}
}
}
回應


