Running into an issue with a streamwriter
I have a web page that has a FileUploader in a loginview to access it I am using
var fileuploader = (FileUpload)LoginView.FindControl("FileUploader");
string filepath = System.IO.Path.GetFullPath(fileuploader.FileName.ToString());
Then I pass that data in to my streamreader which is (in a different class)
using (StreamReader reader = File.OpenText(filename))
The filepath that it is passing in is C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\sample.txt
Where I am selecting it from C:\fasta\sample.txt
I have seen some posts about this, but not concerning asp.net applications. Thanks!
I would suggest using the SaveAs method on the FileUpload control (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.saveas.aspx).
Remember, the file is actually uploaded to you, and from a website, you’ll never really want to care about the location it was at on the client machine (it just so happens the server and client are the same machine for you here). If you uploaded the file to the site from a different machine, the web server would never have access to the resource at the client’s path. The FileUpload control has the file for you, so just take the file, place where you want, and then you can access it and do whatever you want with it.
Cliffs: even if you get the client path to the resource, your server won’t be able to do anything with it since it is on another machine which your server doesn’t have access to.