1

I am making a screenshot program and right now I have a feature that lets the user edit the screenshot in MS Paint. The only problem is, I want the file browser (for saving a paint file) to automatically browse to this path:

%SystemRoot%\system32\mspaint.exe "C:\Users\My Name\Documents\ruush"

Could someone give me some insight into how I would do that?

Here is the code I intend to put it in (in the first if):

DialogResult dialogResult = MessageBox.Show("Would you like to edit your screenshot in paint?", "Edit", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
    Process.Start("mspaint", @"""c:\Users\My Name\Documents\ruush\Screenshot.png""");
}
else if (dialogResult == DialogResult.No)
{
    //do something else
}
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
DavidKenyon96
  • 55
  • 2
  • 9
  • first you don't need paint to do screen shot. there is a function for that. Then look into openfiledialog class. – Steve Mar 06 '18 at 16:53
  • Are you running the code on Windows 10? I believe this is the default behaviour of Paint in Windows 10. In 8 and below it would Save As back to wherever the file was opened from. I'm not aware of a workaround. – Equalsk Mar 06 '18 at 17:02
  • paint isn't doing the screenshot. I am doing that separately with c#. yes im running this on windows 10. I believe i have a workaround which i listed above (%SystemRoot%\system32\mspaint.exe "C:\Users\My Name\Documents\ruush"). I was just looking for a way to implement that in c# – DavidKenyon96 Mar 06 '18 at 17:31

1 Answers1

1

Save the file first, open in Paint second. Paint will remember the location of the file that it already opened.

Rather than forcing Paint, you can also try using the default image editor... though I've seen a lot of systems where the default image program only has view support, so I understand wanting Paint in this case. The best option would be to detect the default image program, and only fall back to MS Paint if you get a result that matches the Photos app, Picture Viewer, or a web browser (more common than you might think).

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • Hey joel. I actually have the screenshots save as a unique name each time (with updated m/d/y timestamp appended to the file name) so the file is saved beforehand; also using paint for this isnt the primary problem. The problem I'm having is making sure that paint, when saving the file after the editing is complete, knows to automatically browse to my specified pathway. the pathway i provided leads to the folder where all the screenshots are saved, so it just makes sense to save the edited images there. – DavidKenyon96 Mar 06 '18 at 17:30
  • @DavidKenyon96 Why does Paint browse anywhere? Paint is opening an existing file that is **already** in the right location. Users will just click the "Save" button and never see the file's location, and it will continue to save in the right place. If someone goes to the extra effort to use "Save As", they probably really do want a different folder than your default, and the normal behavior provided by Windows is correct. – Joel Coehoorn Mar 06 '18 at 17:32
  • I see your point. However, I think it would just be nice to have it open to that specific folder so they are aware of where exactly it is. – DavidKenyon96 Mar 06 '18 at 17:34