c# 調用系統默認圖片瀏覽器打開圖片
阿新 • • 發佈:2019-01-31
viewer -a ogr cep play ESS bin select img
private void OpenImage(string fileName) { try { Process.Start(fileName); } catch (Exception ex) { // LogHelper.WriteLog("調用默認看圖軟件打開失敗", ex); try { stringView Codearg = string.Format( "\"{0}\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen {1} ", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) , fileName);var dllExe = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), "rundll32.exe"); // LogHelper.WriteLog(string.Format("調用系統默認的圖片查看器打開圖片,參數為:{0} {1}", dllExe, arg)); System.Diagnostics.Process.Start(dllExe, arg); }catch (Exception e) { // LogHelper.WriteLog("系統圖片查看器打開圖片失敗", ex); //打開文件夾並選中文件 var argment = string.Format(@"/select,""{0}""", fileName); System.Diagnostics.Process.Start("Explorer", argment); } } }
說明,這個代碼適用於程序的目標平臺為x86
如果是x64,那麽就需要做適當修改
c# 調用系統默認圖片瀏覽器打開圖片