700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > c# 调用系统默认图片浏览器打开图片

c# 调用系统默认图片浏览器打开图片

时间:2020-03-24 07:06:43

相关推荐

c# 调用系统默认图片浏览器打开图片

private void OpenImage(string fileName){try{Process.Start(fileName);}catch (Exception ex){// LogHelper.WriteLog("调用默认看图软件打开失败", ex);try{string arg =string.Format("\"{0}\\Windows Photo Viewer\\PhotoViewer.dll\", ImageView_Fullscreen {1} ",Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), fileName);var dllExe = bine(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);}}}

View Code

说明,这个代码适用于程序的目标平台为x86

如果是x64,那么就需要做适当修改

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。