How can I get the path of a file on my computer or on the local area network.
I would to show a window that allows me to browse the file system when I click a button, and I want to select a file and get the path to the file. How can I do this?
P.S. I’m not looking to upload the file; I just want to get the path.
The web application is running on the server, and you don’t have access to the client file system at all. Can you imagine how much of a vulnerability that would be? I know I don’t want the sites I visit inspecting my file system…
EDIT: Question is for a WinForms application
For a WinForms application, you can use the
OpenFileDialog, and extract the path with something like this:If you’re looking for the file path:
If you’re looking for the directory path:
In general, the
System.IO.Pathclass has a lot of useful features for retrieving and manipulating path information.