ASP.NET有關目錄操作的常識

 MapPath對子目錄操作要帶虛擬目錄名,或者用下面的代替  
  Server.MapPath("/")   --------------站點根目錄的物理路徑  
  Server.MapPath("~/")--------------應用程序根目錄的物理路徑  
  Server.MapPath("./")--------------當前目錄的物理路徑  
  Server.MapPath("../")--------------上級目錄的物理路徑  


using   System.io;  
  //Request.ApplicationPath是程序的虛擬目錄。但操作時要對真實路徑操作,以下就是獲取真實路徑  
  string   filePath   =   Server.MapPath(Request.ApplicationPath);  
  //創建目錄。  
  Directory.CreateDirectory(filePath);  
  //刪除目錄。  
  Directory.Delete(filePath);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章