Open an image with the Windows default editor in C#

后端 未结 2 1774
别跟我提以往
别跟我提以往 2020-12-11 19:42

In my C# application, I would like to launch the default image editor to edit an image.

When I\'m using System.Diagnostics.Process.Start(\"C:\\\\image.png\")

相关标签:
2条回答
  • 2020-12-11 19:55

    If you want open your image in the pictureBox by a Default Winndows Editor try this;

    //Create temporary file name
    String TMP_IMAGE = "tempImage" +DateTime.Now.Millisecond +".bmp";
    
    //get the folder of application
    string PATH_APP =                
            System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\tempImage\";
    
    //Create a subFolder tempImage
    Directory.CreateDirectory(PATH_APP);
    
    //Save a new path in a variable
    String NEW_PATH = PATH_APP + TMP_IMAGE;
    
    //Save the image in the pictureBox in the new path and file name
    pictureBox.Image.Save(NEW_PATH);
    
    //Lunch the process with defaoul image editor in the comouter
    ProcessStartInfo startInfo = new ProcessStartInfo(NEW_PATH);
    Process.Start(startInfo);
    
    0 讨论(0)
  • 2020-12-11 20:19

    You can try starting a process with a verb edit.

    ProcessStartInfo startInfo = new ProcessStartInfo("C:\\image.png");
    startInfo.Verb="edit";
    
    Process.Start(startInfo);
    
    0 讨论(0)
提交回复
热议问题