1. 程式人生 > >c#常用檔案操作

c#常用檔案操作

1.Web 獲取絕對路徑

string filePath = HttpContext.Current.Server.MapPath("~/EmailFiles/"+m.ms_username);

執行緒中:HttpRuntime.AppDomainAppPath.ToString();

From 

Application.StartupPath.ToString();


2.判斷路徑不存在 就 建立
 System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(filePath);
if (!dir.Exists) dir.Create();