- Home /
Deleting and replacing a screenshot after Application.CaptureScreenshot
I have twitter and facebook posting working in-game using Prime31's plugin. I'd like to be able to have a screenshot taken just as the user posts and uploaded with the post. This works using Application.CaptureScreenshot, but the first picture being taken was not being overwritten each time, and only the first picture taken was being used. To try and solve this I added the if statement in my "TakePicture()" method that checks if there is a picture at the filepath and deletes it if there is. This doesn't seem to be working though. I'm not sure why.
Any help would be much appreciated.
Thanks, Matt
void Awake()
{
pictureFilePath = Application.persistentDataPath + "/ScreenShot.png";
}
public void TakePicture()
{
if (System.IO.File.Exists (pictureFilePath) != false)
{
Debug.Log("Hi");
System.IO.File.Delete (pictureFilePath);
}
Application.CaptureScreenshot(pictureFilePath);
}
public void PostToTwitter()
{
TakePicture ();
TwitterBinding.showTweetComposer("Hi there. I'm testing something out in development. FUN!", pictureFilePath, "https://twitter.com/matski53");
}
public void PostToFacebook()
{
TakePicture ();
FacebookBinding.showFacebookComposer("Test", pictureFilePath, "https://twitter.com/matski53");
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613185353im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Taking screenshots on iOS 0 Answers
Location of Application.persistentDataPath ? 6 Answers
How to send an Email with the details entered in a json file? 0 Answers
System.IO.File does not contain a definition for 'WriteAllLines' 1 Answer
How to delete everything at Application.persistentDataPath? 3 Answers