我正在尝试在资源管理器中打开一个文件夹并选择了一个文件。
下面的代码会产生一个找不到文件的异常:
System.Diagnostics.Process.Start(
"explorer.exe /select,"
+ listView1.SelectedItems[0].SubItems[1].Text + "\\"
+ listView1.SelectedItems[0].Text);
如何让这个命令在 C# 中执行?
最佳答案
// suppose that we have a test.txt at E:\
string filePath = @"E:\test.txt";
if (!File.Exists(filePath))
{
return;
}
// combine the arguments together
// it doesn't matter if there is a space after ','
string argument = "/select, \"" + filePath +"\"";
System.Diagnostics.Process.Start("explorer.exe", argument);
关于c# - 在资源管理器中打开文件夹并选择文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/334630/