In a WPF application, when a user clicks on a button I want to open the Windows explorer to a certain directory, how do I do that?
I would expect something like this:
Windows.OpenExplorer("c:\test");
Create a WPF project using Visual Studio and add a TextBox, a Button, and a TextBlock control to page. The final Window looks like Figure 2. Figure 2. When you click the Browse button, we will browse text files and set the selected file name as the text of the TextBox.
With File Explorer open, tap or click the File option at the top of the window and choose Change folder and search options. Once the Folder Options window opens, tap or click the dropdown box for Open File Explorer to and make your choice. Hit OK to save it.
To open a folder, you just specify folder name without /select, part. Something like explorer c:\folder_name . /select option requires an existing file or folder and open its parent and select the item. Thus both options are available.
To open File Explorer, click on the File Explorer icon located in the taskbar. Alternatively, you can open File Explorer by clicking on the Start button and then clicking on File Explorer.
Why not Process.Start(@"c:\test");
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With