Я знаю, что этот вопрос задавался много раз здесь и читал, но я не могу найти решение моей проблемы. Я пытаюсь сохранить изображение в папку в моем проекте: вот мой код позади:C#: Не удалось найти часть пути
if (FileUpload_UploadFile.HasFile)
{
int contentLength = FileUpload_UploadFile.PostedFile.ContentLength;
string contentType = FileUpload_UploadFile.PostedFile.ContentType;
string fileName = FileUpload_UploadFile.PostedFile.FileName;
string imgPath = "~/Image/" + fileName ;
FileUpload_UploadFile.PostedFile.SaveAs(Server.MapPath(imgPath));
}
и это трассировки стека:
[DirectoryNotFoundException: Could not find a part of the path 'C:\Users\.bimanathan\Desktop\PETA\PETA\Image\0eaf985f79f0ceff94aa8c585a31f745_650x.jpg'.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +359
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1305
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +60
System.IO.FileStream..ctor(String path, FileMode mode) +55
System.Web.HttpPostedFile.SaveAs(String filename) +94
PETA.CreateNews.btnSubmit_Click(Object sender, EventArgs e) in c:\Users\.bimanathan\Desktop\PETA\PETA\TEST\CreateNews.aspx.cs:73
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628026
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
Я не знаю, как исправить это, пожалуйста, помогите мне. Я начинаю с C#