How to get file path using FileUpload to be read by FileStream?

Posted by john ryan on Stack Overflow See other posts from Stack Overflow or by john ryan
Published on 2011-06-24T06:53:07Z Indexed on 2011/06/24 8:22 UTC
Read the original article Hit count: 185

Filed under:
|

I have a Method that open excel file and read it through exceldatareaderClass that i have downloaded in codeplex by using filestream.

Currently I just declared the exact directory where the filestream open an excel file.And it works fine.

Stream stream = new FileStream("C:\\" + FileUpload.PostedFile.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);

Now i need to read the excel file wherever location the user place it like on windows forms fileupload.FileStream needs the exact location where the file is located. How to do this.?

Example: Sample.xls is located on My Documents

the file path should be like : C:\Documents and Settings\user\My Documents\

string openpath ="" ;//filepath

    Stream stream = new FileStream(openpath+ FileUpload.PostedFile.FileName, FileMode.Open, FileAccess.Read, FileShare.Read);

Thanks in Regards

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about file-upload