c#常用文件操作
2017-11-17 12:14
183 查看
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();
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();