Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 10, 2012 12:18 AM by lesponce
Dec 06, 2012 01:05 AM|LINK
I'm using the asp.net control file upload which works great on my development machine. On the test server it fails. Any ideas?
Error: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\myuser\Desktop\Test.csv'.
On the server I'm using:
fileName = Server.MapPath(FileUpload1.PostedFile.FileName);
Dec 06, 2012 01:52 AM|LINK
Dec 06, 2012 01:59 AM|LINK
Thank you. I'm getting the same behavior. :(
Dec 06, 2012 02:01 AM|LINK
Do you want file in fileupload saved to server? Your code wrong
string sfile = FileUpload1.FileName; //getfile name example report.doc
string spath = Server.MapPath("~/folderupload"); //get target folder path example d:\myweb\folderupload
string sfullpath = spath + @"\" + sfile; // combine to d:\myweb\folderupload\report.doc
FileUpload1.SaveAs(sfullpath); //save the file to the location
Dec 06, 2012 02:04 AM|LINK
I'm importing a csv file. When I click my import button, the csv data is read and saved into a database. Which way should I go?
Dec 06, 2012 02:09 AM|LINK
Oh I see...... the file is uploaded and saved into a directory on the server. Then, I should read the saved file to process my data import. Correct?
Dec 06, 2012 02:13 AM|LINK
yes, save it to server and use it. Use sfullpath ro read the file.
Dec 06, 2012 02:15 AM|LINK
Thanks oned_gk, I will give it a shot.
Dec 06, 2012 02:55 AM|LINK
hhmm... not sure why I'm still getting "could not find part of the path" c:\user\myuser\path\file.csv Any thoughts?
Dec 06, 2012 03:10 AM|LINK
I'm getting error:
Could not find a part of the path 'C:\Users\xxxxxx\Desktop\Test.csv'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\xxxxx\Desktop\Test.csv'.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.