C#實現打開文件或文件夾及選中文件

打開文件夾

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爲文件路徑不包含文件名)

擴展提示:可以採用 Application.StartupPath 獲得應用程序所在的目錄。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章