我有以下操作方法,该方法将上载的文件添加到文件夹:
if (ModelState.IsValid)
{
string ADusername = User.Identity.Name.Substring(User.Identity.Name.IndexOf("\\") + 1);
repository.InsertOrUpdateDataCenter(dc, ADusername);
repository.Save();
if (DataCenterfile != null)
{
var fileName = Path.GetFileName(DataCenterfile.FileName);
var path = Path.Combine(Server.MapPath(Url.Content("~/Content/uploads")), dc.ID + ".png");
DataCenterfile.SaveAs(path);
}
return RedirectToAction("Details", new { id = dc.ID });
}
但我收到以下异常:-
Server Error in '/TMS' Application.
Could not find a part of the path 'C:\inetpub\wwwroot\TMS\Content\uploads\97.png'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\inetpub\wwwroot\TMS\Content\uploads\97.png'.
Source Error:
记住上面的方法运行良好,但是在将Web应用程序发布到IIS之后,我开始收到此错误。所以任何人都可以建议我如何解决这个问题?谢谢
Upload文件夹不在IIS内,因此我必须手动发布它。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句