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);
		StartCoroutine(MyMethod());
	}

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.

http://stackoverflow.com/questions/2081449/is-it-possible-to-access-private-var-root-media-dcim-100apple-on-a-non-jailbrok

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