当前位置:编程学习 > C#/ASP.NET >>

目录检查和创建问题

我先进行判断,如果不存在再进行新建目录,下面的代码为什么还会报错:找不到指定的路径
         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#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,