C# Saving Screenshot to Device "Cannot Find Filename" error

Please forgive any noob mistakes in the code – I’m not at all familiar with C# :frowning:

The code below should take a screenshot on the device and then save to the device’s photos. It seems to get stuck saving the photo.

Any ideas where I’m going wrong?

	IEnumerator MyMethod() {
		yield return new WaitForSeconds(2);
	        var pathToImage = Application.persistentDataPath + "/" + saveToDiskScript.screenshotFilename;
		var bytes = System.IO.File.ReadAllBytes( pathToImage );
		System.IO.File.WriteAllBytes("private/var/root/Media/DCIM/100APPLE/" + screenshotFilename, bytes);

        public void TakeSnapshot()
		Application.CaptureScreenshot( screenshotFilename );
	        print ("Taking, " + screenshotFilename);

The error I receive, in XCode: [Edited – I made the WaitForSeconds 5 instead of 2, and now I get this error – an improvement than before!]

IsolatedStorageException: Could not find a part of the path “/private/var/root/Media/DCIM/100APPLE/SomethingToThinkAbout03-05-201306:59:38.png”.

The debug log does show: SomethingToThinkAbout03-05-201306:59:38.png as the file name.

I think the problem may be an access problem to that folder location. If the device is not jailbroken then that folder path is not available.


Try another save location with this same code to test this.