I'm trying to delete file on iOS. I've tried the following in C# script:
System.IO.File.Delete("file://" + Application.persistentDataPath+"/"+"SnapShot5.png");
I've also tried: File.Delete("SnapShot5.png");
That didn't work either. I have the using System.IO; in the first line of the script and checking File exists with: System.IO.File.Exists in the same script works, but not deleting line.
Any ideas? Thx
Try changing your path to include "/private" at the beginning, like so:
string filePath4Realz = "/private" + oldFilePath
Also make sure you don't prepend with "file://".
I'm not sure why this works; it looks like iOS needs this at the beginning if you want to make changes to your files. Hopefully someone else can chime in to say if this is a horrible idea, but it works for me.
Edit: you will of course want to conditionally add this to your path if you're on iOS. You don't want to do this with the unity player. Something like "#if UNITY_IPHONE" should work fine.