问题
I am working with files and I don't really understand how to make it work.
I have a web application (c#) that is located on the server and users use this application to upload some information from the files. The problem that I am having that users upload the file (using HttpPostedFileBase
class) from their local machines but code is trying to match the same path on the server and of course the file doesn't exist on the server, that's why it throws an error saying that
Cannot find a part of the path ...
If the user is trying to upload the file from C:\Users\User1\Documents\File.txt
from their local machine how can I write the code to include the whole path to the file including the computer name and the local drive something like \\ComputerName\c$\Users\User1\Documnets\File.txt
.
回答1:
You can't. Client and servers are disconnected from each other. That is how the web works. You can't get the full client path and access that in any way from the server.
There are very good reasons for this, the most important one is security / trust.
来源:https://stackoverflow.com/questions/27609849/full-path-of-the-file-from-the-remote-server