In my C# application (using Visual Studio 2010 ultimate) the user needs to select a certain file. I’ve created a basic file explorer which pretty much works but doesn’t look great.
I’ve been asked to use the standard Windows file Explorer.
I know how to open it:
Process.Start("explorer.exe");
But how can I get a file path returned from it?
To select a file, the Net Framework provides the OpenFileDialog component.
You can see the reference at MSDN here
But basically, all you have to do is:
Create an Instance of OpenFileDialog
Set the initial property
Open the control calling the ShowDialog, wait for the OK press from the user and grab the file selected
Notice the using statement around the OpenFileDialog(), while not strictly necessary this will assure the Disposing of the dialog