引用:using System.Diagnostics;
打开文件夹:
System.Diagnostics.Process.Start(FilePath);
打开文件夹中某个文件:
System.Diagnostics.Process.Start(FilePath+"/"+FileName);
打开文件夹并选中单个文件:
System.Diagnostics.Process.Start("Explorer",
"/select,"+ FilePath+"\\"+FileName);
或
System.Diagnostics.Process.Start("Explorer.exe",
"/select,"+ FilePath+"\\"+FileName);
用IE打开文件:
System.Diagnostics.Process.Start("Explorer",FilePath+"\\"+FileName);
System.Diagnostics.Process.Start("Explorer.exe",FilePath+"\\"+FileName);
注:(explorer,explorer.exe,select,不区分大小写,"/selecet,"其中"/,"都不能少,FilePath为文件路径不包含文件名)
注意:filepath中的路径格式应该用“\\”,不能用“/”,不然会出现“the path does not exist or is not a directory”的错误。
例:"D:\\dennis\\Dennis\\learning\\asp.net\\trainning\\convertDell\\text\\sta\\text.sta"正确
"D:/dennis/Dennis/learning/asp.net/trainning/convertDell/text/sta/text.sta" 错误
本文介绍如何使用C#中的System.Diagnostics命名空间来启动文件夹、打开特定文件以及在文件浏览器中高亮显示指定文件的方法。此外还提供了用IE打开文件的示例代码。
8632

被折叠的 条评论
为什么被折叠?



