WebClient FileUpload - 上传文件问题

问题描述

我正在尝试使用网络磁盘上的 WebClient 上传文件。 一切都很好,直到我发布我的应用程序。 上传代码

public IFormFile Image{ get; set; }
(...)
imagename = FileHelper.GenerateFilename(Image.FileName);
var imgsave = Path.Combine(PathHelper.NewsFilePath,imagename);

WebClient client = new WebClient();
client.Credentials = new NetworkCredential("username","password");

try
{
    client.UploadFile(imgsave,Image.FileName);
}
catch (Exception e)
{
}

当我在本地运行应用程序时,它运行良好,但是当我发布我的应用程序时,出现错误

Error message: System.IO.FileNotFoundException: Could not find file 'C:\inetpub\wwwroot\application\test.PNG'. 
File name: 'C:\inetpub\wwwroot\application\test.PNG' at (...)

似乎已发布的应用程序正在应用程序文件夹中的某处寻找此文件。如何指示此文件正确上传

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)