在运行中,输入 Explorer /select,C:WindowsSystem32cmd.exe 达到打开文件夹并选择文件夹内的一个文件的目的
打开文件所在位置并且选中这个文件
public void ExplorerFile(string path)
{
System.Diagnostics.Process.Start("explorer.exe", @"/select," + path);
}
|
打开文件夹
public void ExplorerDirectory(string path)
{
System.Diagnostics.Process.Start("explorer.exe",path);
} |
使用
private void button4_Click(object sender, EventArgs e)
{
ExplorerFile(@"C:WindowsSystem32cmd.exe");
ExplorerDirectory(@"C:windows");
} |