C# 上载后找不到该文件
我正在网站上工作,你可以将多个PDF文件合并成一个文件 但我面临的问题是,每次尝试上载文件时,都会出现以下错误:C# 上载后找不到该文件,c#,C#,我正在网站上工作,你可以将多个PDF文件合并成一个文件 但我面临的问题是,每次尝试上载文件时,都会出现以下错误: Could not find file 'C:\Program Files (x86)\IIS Express 我已经从这个路径(C:\Program files(x86)\IIS Express)上传了文件,以使其正常工作 我的代码: protected void Button1_Click(object sender, EventArgs e) { string fi
Could not find file 'C:\Program Files (x86)\IIS Express
我已经从这个路径(C:\Program files(x86)\IIS Express)上传了文件,以使其正常工作
我的代码:
protected void Button1_Click(object sender, EventArgs e)
{
string filepath = Server.MapPath("\\Upload");
HttpFileCollection uploadedFiles = Request.Files;
Span1.Text = string.Empty;
for (int i = 0; i < uploadedFiles.Count; i++)
{
HttpPostedFile userPostedFile = uploadedFiles[i];
if (userPostedFile.ContentLength > 0)
{
userPostedFile.SaveAs(filepath + "\\" + Path.GetFileName(userPostedFile.FileName));
Span1.Text += "Location where saved: " + filepath + "\\" + Path.GetFileName(userPostedFile.FileName) + "<p>";
}
}
受保护的无效按钮1\u单击(对象发送者,事件参数e)
{
字符串filepath=Server.MapPath(“\\Upload”);
HttpFileCollection uploadedFiles=Request.Files;
Span1.Text=string.Empty;
对于(int i=0;i0)
{
userPostedFile.SaveAs(filepath+“\\”+Path.GetFileName(userPostedFile.FileName));
Span1.Text+=“保存位置:”+filepath+“\\”+Path.GetFileName(userPostedFile.FileName)+“”;
}
}
尝试在此处使用相对路径:Server.MapPath(“\\Upload”)
=>Server.MapPath(“~/Upload”)
谢谢您的重播,但我收到了相同的错误。请发送代码blockHüseyin BurakKaradag我在此处添加了问题中的代码尝试使用相对路径:Server.MapPath(\\Upload”)
=>Server.MapPath(“~/Upload”)
感谢您的重播,但我收到了相同的错误。请发送代码blockHüseyin BurakKaradag我在上面的问题中添加了代码