Failed to store screen shot

I’m trying to a store screenshot but keep getting this error, even though there should be no access issues with the dest path. My code is

string date = System.DateTime.Now.ToString();
date = date.Replace("/","-");
date = date.Replace(" ","_");
Application.CaptureScreenshot(Application.dataPath + "/../SS_"+date+".png");

dataPath isn’t writable, but up 1 directory is. I’m running this from a built exe too, not from within the editor.

As you might know it’s prohibited to use some characters in naming folders and files (File Naming)

exemple of System.DateTime.Now output: 10/2/2017 11:56:56 AM,
you have replaced the slash “/” but you forgot about the Colon “:” + you are storing in a sub-folder with the name “…”

string date = System.DateTime.Now.ToString();
 date = date.Replace("/","-");
 date = date.Replace(" ","_");
date = date.Replace(":","-");
 Application.CaptureScreenshot(Application.dataPath + "/ScreenShots/SS_"+date+".png");

For writing stuff that you want to save from your Unity game I recommend to either write to the StreamingAssets folder in your game files or to a specific folder on the user’s computer, E.G Document/YourGameName/Screenshots. This guarantees that the folder is not in use and that writing is enabled.

Check if the options I gave you work, if they do, there likely is something wrong with your path, even if you thought there wasn’t.

~LukeWaffel