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
The FileUpload property PostedFile.InputStream already represents the stream that you create in your example.
Note that the FileName property stores the file name on the client, not the file name on the server.
You cannot expect that the uploaded file is present as a physical file on the server, just use the InputStream to read the uploaded data.