paint.exe cant find saved image folder

I capture screenshots in my game and use paint to call it up the problem is the paint application cannot find the path where the picture is saved or is searching for it in the wrong directory as i get this error “C:\User\user\Documents\project\Mytree-0 was not found”.Please i need help with this my code is below.
Thanks

Application.CaptureScreenshot( System.IO.Path.Combine(
        System.Environment.GetFolderPath( System.Environment.SpecialFolder.MyPictures ),
            "MyTree-" + PlayerPrefs.GetInt("HighScore") + ".png") );
	yield WaitForSeconds(2);
	
	System.Diagnostics.Process.Start("mspaint.exe","MyTree-" + PlayerPrefs.GetInt("HighScore") + ".png");

You are passing different values to CaptureScreenShot() and Start().

CaptureScreenShot() is receiving a fully qualified path, while Start() (and by extension mspaint.exe) is receiving only a filename.

As a result windows is mapping the filename to the current working directory.


I suggest making liberal use of intermediate variables when they will enhance readability and consistency. As a bonus they can make debugging unexpected behaviour easier.

Here is an alternative implementation:

var directory: String = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures);
var filename: String = "MyTree-" + PlayerPrefs.GetInt("HighScore") + ".png";
var filepath: String =  System.IO.Path.Combine(directory, filename);
	
Debug.Log("filepath: " + filepath);
	
Application.CaptureScreenshot( filepath );
yield WaitForSeconds(2);
System.Diagnostics.Process.Start("mspaint.exe", filepath);