Unable to find path of the file.

Posted by Laghaterohan under Regular Expressions on 1/31/2011 | Points: 10 | Views : 1768 | Status : [Member] | Replies : 3
Hello,

I am using FileUpload control to browse an Excel file...the code works absolutely fine on the development site. However, when i deployed my application i got an error when i did R N D on the same i got a solution that says we need to save the file using PostedFile.SaveAs() ...
I did the above and now i am getting a new error which says:
Could not find a part of the path

Can any one tell me where am i going wrong...? I am unable to browse my excel file...

here is my code snippet..

if (fileup.HasFile == true)
{
string fileName = fileup.PostedFile.FileName;
fileup.PostedFile.SaveAs(fileName);
}

Please tell me how to solve the error....
Thanks!

Best Regards,
Rohan Laghate



Responses

Posted by: Vuyiswamb on: 1/31/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Look at this
http://www.dotnetfunda.com/articles/article1062-fileupload--uploading-file-to-the-server-without-clicking-a-button-.aspx

Thank you for posting at Dotnetfunda
[Administrator]

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sathya4260 on: 1/31/2011 [Member] Starter | Points: 25

Up
0
Down
See my blog:

Here I provided the full code

http://sathya4260.blogspot.com

Sathish Kumar S

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 1/31/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi rohan...


i think u miss your folder when u save excel files ...
u write code like this ..

string strPath = Server.MapPath("~/doc/");
FileUpload1.SaveAs(strPath + FileUpload1.FileName);

Best Regard's
Prabhakar

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response