C#中判断文件或文件夹是否存在
if (Directory.Exists(Server.MapPath("~/upimg/hufu")) == false)//如果不存在就创建file文件夹 { Directory.CreateDirectory(Server.MapPath("~/upimg/hufu")); } //Directory.Delete(Server.MapPath("~/upimg/hufu"), true);//删除文件夹以及文件夹中的子目录,文件 //判断文件的存在 if (File.Exists(Server.MapPath("~/upimg/Data.html"))) { //存在文件 } else { //不存在文件 File.Create(MapPath("~/upimg/Data.html"));//创建该文件 }
转载于:https://www.cnblogs.com/mahongbo/archive/2009/02/28/1400217.html
相关资源:JAVA上百实例源码以及开源项目