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;
Praveen VenugopalPosted Aug 14, 2008, 1:27 AM
The Answer is :
HttpFileCollection files = Request.Files;
for (int p = 0; p < files.Count; p++){
HttpPostedFile file = files[p];if (file.ContentLength == 0){
continue;}
string c = System.IO.Path.GetFileName(String.Format(file.FileName));string path = Server.MapPath("../")+"Upload"+ @"\" +c;
StreamWriter streamWriter;streamWriter = File.CreateText(path);streamWriter.Close();
file.SaveAs(path);