1
Answer

Error while saving the Uploaded files

Hello There!,

I am having an error while saving the uploaded files.

it says"part of the path could not be found"

actually i wanted to save the uploaded files with in my Solution

My Code is


HttpFileCollection uploads = HttpContext.Current.Request.Files;

for (int i = 0; i < uploads.Count; i++)

{

HttpPostedFile upload = file;

if (upload.ContentLength == 0)

{

continue;

}

string c = System.IO.Path.GetFileName(upload.FileName);

try

{
string path = Server.MapPath(".")+"\\Upload\\" + c;

StreamWriter streamWriter;
streamWriter = File.CreateText(path);
streamWriter.Close();

upload.SaveAs(path);

Span1.InnerHtml = "Upload(s) Successful.";

}


Could you please tell me whats the error?

actually i had created an Empty folder called "Upload" with in my Solution

I had also tried

string path = Server.MapPath("Upload\\") + c;

Answers (1)