May 20, 2010

Open Explorer At Some Directory in C#

Use the following code snippet:
// Open explorer in user temporary directory
OpenExplorerInDir(System.IO.Path.GetTempPath());
...
private void OpenExplorerInDir(string dir)
{
  string exe = "explorer.exe";

  //Driectory.Exists
  Process exeProcess = new Process();
  exeProcess.StartInfo.FileName = exe;
  exeProcess.StartInfo.Arguments = "/e,/root," + dir;
  exeProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
  exeProcess.Start();
}

No comments: