Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open windows explorer with WPF application directory

Tags:

c#

I want to open application directory with button click. i get such error

enter image description here

Does anyone have an idea?

like image 817
Irakli Lekishvili Avatar asked Dec 03 '25 16:12

Irakli Lekishvili


1 Answers

If you set UseShellExecute to true, then you can use Process to open a directory. For example, this will open the C:\ drive. You can specify any path you want.

Process process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = @"C:\";
process.Start();

This is similar to using the Run dialog from the start menu. For instance, even though a Word document is not a program, using Shell Execute will allow you to "Start" a word document by using whatever program is associated with it. Likewise the same with a directory.

like image 108
vcsjones Avatar answered Dec 05 '25 22:12

vcsjones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!