刪除某一目錄的某一檔案 @ R~福氣拉! :: 隨意窩 Xuite日誌
  • BloggerAds
  • 關鍵字
  • Search Google
  • Google
    1. 沒有新回應!
  • 看起來滿像樣
  • 工商時間
  • 2009-05-12 21:46 刪除某一目錄的某一檔案
    平均分數:0 顆星    投票人數:0
    我要評分:

    刪除某一目錄的某一檔案

     ---------------------------------------------------------

    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);
                    }
     }       
    }

     

    小米 / Xuite日誌 / 回應(0) / 引用(0) / 好文轉寄
    回應