[U3DXT] Deleting a screenshot after posting it.

Hi! I’m reffering to the tutorial here http://unity3d.tutsmobile.com/how-to-take-a-screenshot-and-share-it-on-ios/

The problem I have is that after I take the screenshot it doesn’t delete itself… To counter the problem and not having to retake the screenshot 2 times to have a new screenshot I save the index to player pref… But the problem is that the screenshot are now taking place on the iphone… can you guys help me?

Here is my code.

	private bool _captured = false;
	public static int index = 0;
	
	void screenshotFB() {
		index = PlayerPrefs.GetInt("screenshot");
		Application.CaptureScreenshot("screenshot"+index+".png");
		_captured = true;
		sendScreenShottoFb();
		Debug.LogWarning("ScreenshottoFB");
	}
	void screenshotTwitter() {
		index = PlayerPrefs.GetInt("screenshot");
		Application.CaptureScreenshot("screenshot"+index+".png");
		_captured = true;
		sendScreenShottoTwitter();
		Debug.LogWarning("ScreenshottoTwitter");
	}
	
	void sendScreenShottoFb() {
		if ( _captured && System.IO.File.Exists(Application.persistentDataPath + "/screenshot"+index+".png") )
		{
			Debug.Log("screenshot exists: " + Application.persistentDataPath + "/screenshot.png");
			UIImage tmp = new UIImage(Application.persistentDataPath + "/screenshot"+index+".png");
			SocialXT.Post(SLRequest.SLServiceTypeFacebook, "#AwesomeBoots HighScore", tmp.ToTexture2D(), "http://awesomebootsgame.com", true);			
			System.IO.File.Delete("/private" + Application.persistentDataPath + "/screenshot"+index+".png");
			_captured = false;
			index++;
			PlayerPrefs.SetInt("screenshot", index);
			delete ();
		}
	}
	void sendScreenShottoTwitter() {
		if ( _captured && System.IO.File.Exists(Application.persistentDataPath + "/screenshot"+index+".png") )
		{
			Debug.Log("screenshot exists: " + Application.persistentDataPath + "/screenshot.png");
			UIImage tmp = new UIImage(Application.persistentDataPath + "/screenshot"+index+".png");
			SocialXT.Post(SLRequest.SLServiceTypeTwitter, "#AwesomeBoots HighScore", tmp.ToTexture2D(), "http://awesomebootsgame.com", true);			
			System.IO.File.Delete("/private" + Application.persistentDataPath + "/screenshot"+index+".png");
			_captured = false;
			index++;
			PlayerPrefs.SetInt("screenshot", index);
			delete ();
		}
	}
	void delete() {
		System.IO.File.Delete("/private" + Application.persistentDataPath + "/screenshot"+index+".png");
	}
	
}

Thank you!!!

Not sure why it doesn’t delete the file. Maybe put it in a different folder instead, like Application.temporaryCachePath. Or Delete it one frame later.