【发布时间】:2017-09-10 01:54:38
【问题描述】:
我在我的 Web 应用程序中使用 FileUploader 控件。我想将文件上传到指定的文件夹中。由于具体的文件夹还不存在,我必须在我的代码中创建它的路径。
string folder = System.IO.Path.GetFileNameWithoutExtension(FileUpload1.FileName);
string path = Request.PhysicalApplicationPath + "/" + folder;
if (!System.IO.Directory.Exists(path))
System.IO.Directory.CreateDirectory(path);
string server_path = Request.PhysicalApplicationPath + "/myfiles/";
FileUpload1.SaveAs(server_path + FileUpload1.FileName);
【问题讨论】:
-
如果你确定路径是相同的,为什么你有
path和server_path变量?显然它们是不同的,这就是您收到错误的原因。 -
即使我改变它
-
仍然出现同样的错误
标签: c# asp.net file file-upload directory