2012-03-26 52 views
3

我正在保存文件(圖像,Excel文檔,Word文檔,exe文件,蝙蝠文件等)。我需要從我的程序中執行文件,問題是是否有辦法讓Windows處理如何運行/執行文件?就像在瀏覽器中雙擊文件時一樣?讓Windows決定如何打開/運行該文件?

+0

可能重複http://stackoverflow.com/questions/258416/shellexecute-equivalent-中網) – 2012-03-26 09:37:52

回答

13

Process.Start方法請看:

System.Diagnostics.Process.Start(myFileName) 

注:這將與任何已註冊的文件擴展工作,例如

System.Diagnostics.Process.Start(@"c:\Image.bmp") 

將打開圖像與註冊的程序。

3

與保存的文件路徑名作爲參數,啓動新的進程:

System.Diagnostics.Process.Start(pathToYourFile); 
[ShellExecute的等同於.NET(的
相關問題