Quote:
String MyExcelFile = MyInput1.PostedFile.FileName;
The
FileName
property returns the path - or sometimes just the name - of the file
on the client.
Your code is running
on the server. It does not have access to the client's file system.
It
appears to work when you're debugging in Visual Studio. But that's only because, in that specific case, the client and server happen to be the same.
You have two options:
- Use
MyInput1.SaveAs(...)
to save the file somewhere on the server, and then read the server's copy. You will need to use a random filename, since multiple users might be accessing your site at the same time, and you don't want the file from one user to overwrite the file from a different user. - Use a library which lets you read the file from a
Stream
, without saving it to disk. You can then pass in MyInput1.FileContent
, which gives you access to the raw content of the uploaded file.