c#常用文件操作

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/rrrgy236116/article/details/78559745

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

猜你喜欢

转载自blog.csdn.net/rrrgy236116/article/details/78559745