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'.
Source Error:
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.
lesponce
Member
109 Points
320 Posts
File Upload Problem
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:
string fileName = Server.MapPath(FileUpload1.PostedFile.FileName);
ignatandrei
All-Star
137598 Points
22126 Posts
Moderator
MVP
Re: File Upload Problem
Dec 06, 2012 01:52 AM|LINK
Server.MapPath(Path.GetFileName(FileUpload1.PostedFile.FileName)))
lesponce
Member
109 Points
320 Posts
Re: File Upload Problem
Dec 06, 2012 01:59 AM|LINK
Thank you. I'm getting the same behavior. :(
oned_gk
All-Star
35734 Points
7299 Posts
Re: File Upload Problem
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 locationSuwandi - Non Graduate Programmer
lesponce
Member
109 Points
320 Posts
Re: File Upload Problem
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?
lesponce
Member
109 Points
320 Posts
Re: File Upload Problem
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?
oned_gk
All-Star
35734 Points
7299 Posts
Re: File Upload Problem
Dec 06, 2012 02:13 AM|LINK
yes, save it to server and use it. Use sfullpath ro read the file.
Suwandi - Non Graduate Programmer
lesponce
Member
109 Points
320 Posts
Re: File Upload Problem
Dec 06, 2012 02:15 AM|LINK
Thanks oned_gk, I will give it a shot.
lesponce
Member
109 Points
320 Posts
Re: File Upload Problem
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?
lesponce
Member
109 Points
320 Posts
Re: File Upload Problem
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'.
Source Error:
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.