Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
432 views
in Technique[技术] by (71.8m points)

.net - Open an image with the Windows default editor in C#

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") it opens the image file using the Windows Photo Viewer.

When I right-click on the image file in Windows Explorer, there is a "Edit" menu item which launches Microsoft Paint (by default). I would like to do the same in my application (i.e. open the file using the default image editor).

I don't want to hardcode MS Paint by doing Process.Start("mspaint.exe C:\image.png"). I would prefer to use the default image editor program set by the user (which can be different from MS Paint).

Is there a way to do this?

Thanks Frank

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can try starting a process with a verb edit.

ProcessStartInfo startInfo = new ProcessStartInfo("C:\image.png");
startInfo.Verb="edit";

Process.Start(startInfo);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...