zoukankan      html  css  js  c++  java
  • 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 = 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);
                    }
                }
            }
    View Code

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

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

  • 相关阅读:
    【iOS】打印方法名
    【iOS】设备系统版本
    【iOS】receiver type *** for instance message is a forward declaration
    【iOS】获取应用程序本地路径
    hash算法
    redis文档
    Couchbase
    nodejs多核处理
    基于nodejs的消息中心
    nodejs两个例子
  • 原文地址:https://www.cnblogs.com/sczmzx/p/10340866.html
Copyright © 2011-2022 走看看