目录检查和创建问题
我先进行判断,如果不存在再进行新建目录,下面的代码为什么还会报错:找不到指定的路径private string galleryPath = "../Gallery/";
string dirPath = galleryPath + "2008/11/" + folder_ref;
if (Directory.Exists(dirPath) == false)
{
Directory.CreateDirectory(dirPath);
}
Request.Files["SourceFile_1"].SaveAs(Server.MapPath(dirPath + "/O_" + fileName)); --------------------编程问答-------------------- folder_ref是什么?
LZ单步调试一下看看异常是在哪句抛出的吧 --------------------编程问答-------------------- 当然错啦,要先Mappath --------------------编程问答-------------------- private string galleryPath = Server.MapPath("../Gallery/");
string dirPath = galleryPath + "2008/11/" + folder_ref;
if (Directory.Exists(dirPath) == false)
{
Directory.CreateDirectory(dirPath);
}
Request.Files["SourceFile_1"].SaveAs(dirPath + "/O_" + fileName); --------------------编程问答-------------------- 谢谢,问题已经解决
补充:.NET技术 , C#