C# 定位到指定文件

定位单个文件:

 

string arguments = string.Format("/select,\"{0}\"", filePath);
System.Diagnostics.Process.Start("Explorer", arguments);

或者

 

string arguments = string.Format("/select,\"{0}\"", filePath);
System.Diagnostics.Process.Start("Explorer.exe", arguments);

注:explorer、explorer.exe、select,不区分大小写。”/selecet,”其中”/,”都不能少,filePath为文件路径。
---------------------------------------------------------------------------------------------------------------

用IE打开文件:

System.Diagnostics.Process.Start("Explorer",filePath);

或者

System.Diagnostics.Process.Start("Explorer.exe",filePath);

---------------------------------------------------------------------------------------------------------------

打开文件夹:

System.Diagnostics.Process.Start(directoryPath);

---------------------------------------------------------------------------------------------------------------

打开文件夹中某个文件:

System.Diagnostics.Process.Start(filePath);
---------------------------------------------------------------------------------------------------------------

posted @ 2022-04-28 12:04  一条袜子  阅读(260)  评论(0编辑  收藏  举报