Irakli Lekishvili
Irakli Lekishvili

Reputation: 34158

Open windows explorer with WPF application directory

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

enter image description here

Does anyone have an idea?

Upvotes: 3

Views: 5755

Answers (3)

vcsjones
vcsjones

Reputation: 141638

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.

Upvotes: 5

Philipp Schmid
Philipp Schmid

Reputation: 5828

Try setting the ProcessStartInfo.Verb to "Open".

Upvotes: 0

CodeWarrior
CodeWarrior

Reputation: 7468

Have you tried "explorer.exe {0}" ? Explorer is the process you want, and the argument your intended path.

Upvotes: 1

Related Questions