How to use MapPath() function while uploading a file using FileUpload control
-
i am creating a directory using code
string path="C:/My Documents/"; Directory.CreateDirectory(path);
directory is created successfully and i can view it in my c drive, now if i tries to upload a file using codeif (FileUpload1.HasFile) { path += FileUpload1.FileName; FileUpload1.SaveAs(MapPath(path)); }
it produces an error message showing "virtual path 'C:/My Documents/fileName' does not exists" while path do exists in my drive. any suggestion about the reason of this error. Thanks in advance.- A programmer's national anthem; "AAAAAHHHHH!!!!"
-
i am creating a directory using code
string path="C:/My Documents/"; Directory.CreateDirectory(path);
directory is created successfully and i can view it in my c drive, now if i tries to upload a file using codeif (FileUpload1.HasFile) { path += FileUpload1.FileName; FileUpload1.SaveAs(MapPath(path)); }
it produces an error message showing "virtual path 'C:/My Documents/fileName' does not exists" while path do exists in my drive. any suggestion about the reason of this error. Thanks in advance.- A programmer's national anthem; "AAAAAHHHHH!!!!"
-
Mappath is used to get the physical path from a virtual one. In your case you already provide the physical path so you don't need to use the beforementioned method.