CSharp examples for System.Windows.Forms:Dialog
Opens Windows Explorer window with specified file selected.
using System.Windows.Forms; using System.IO;//from w w w. jav a 2s .c om using System.Diagnostics; public class Main{ /// <summary> /// Opens Windows Explorer window with specified file selected. /// </summary> public static void StartExplorerForFile(string path) { if (string.IsNullOrEmpty(path)) return; // if file doesn't exits, try to open its parent folder: if (!File.Exists(path)) { StartExplorer(Path.GetDirectoryName(path)); return; } // open Explorer window with specified file selected: Process.Start("Explorer.exe", "/select,\"" + path + "\""); } }