Opening a folder in Windows Explorer with WPF

17 11 2009

Today on my way to work I was working on a button for my Imageviewer. The button was supposed to open the download folder to which the user had chosen to save his/her images. 

image 
To open a folder in WPF we use the following code:

            //Go to the specified folder

            var runExplorer = new System.Diagnostics.ProcessStartInfo();

            runExplorer.FileName = "explorer.exe";

            runExplorer.Arguments = @"C:\Downloads\";

            System.Diagnostics.Process.Start(runExplorer);

“explorer.exe” here refers to the Windows Explorer and its arguments are equal to the path where we want to go. It’s a fairly simple script but very useful.

 

Today’s song (Click for Spotify link)

image

Advertisements

Actions

Information

One response

3 07 2012
chimeco795

try
{
var runExplorer = new System.Diagnostics.ProcessStartInfo();
runExplorer.FileName = “explorer.exe”;
runExplorer.Arguments = @”\\172.18.53.180\c$\”;
runExplorer.UserName = “administrator”;
runExplorer.Password = ConvertToSecureString(“atentoadmin”);
runExplorer.RedirectStandardError = true;
runExplorer.RedirectStandardOutput = true;
runExplorer.UseShellExecute = false;

System.Diagnostics.Process.Start(runExplorer);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: