c#常用文件操作

c#常用文件操作

1.Web 获取绝对路径

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

线程中:HttpRuntime.AppDomainAppPath.ToString();

From 

Application.StartupPath.ToString();

 

2.判断路径不存在 就 创建 if (!dir.Exists) dir.Create();

 

3.判断路径存在删除

if (Directory.Exists(thispath))
                        Directory.Delete(thispath + "\log",true);

//创建

Directory.CreateDirectory(thispath+"\log");

posted @ 2021-01-05 13:00  不要摸我的腰  阅读(54)  评论(0编辑  收藏  举报