string PathForFile(string filename) {
if (Application.platform == RuntimePlatform.IPhonePlayer){
string path = Application.persistentDataPath.Substring(0,Application.persistentDataPath.Length - 5);
path = path.Substring(0,path.LastIndexOf(‘/’));
return Path.Combine(Path.Combine(path, “Documents”), filename);
}
else if(Application.platform == RuntimePlatform.Android){
string path = Application.persistentDataPath;
path = path.Substring(0,path.LastIndexOf(‘/’));
return Path.Combine(path, filename);
}
else{
string path = Application.dataPath;
path = path.Substring(0, path.LastIndexOf(‘/’));
return Path.Combine(path, filename);
}
}
when using this method my saved png and wav files work just fine. They are retrieved and displayed or played with the path returned.
However, once i restart the app on my iPhone or iPad, they don’t work anymore!
I get URL not correct for playing the wav file as an audio clip and get isolatedstrorageexception for png files. Even though the path is correct and was working just fine before restarting the device!
I use the above method along with a file name which has incremented int and save each one’s path as string in a file that also reside in the Application.persistentDataPath, and that file has no problem at all when i retrieve it and it’s a dat file.
Now if the .dat file works just fine, shouldn’t also .wav and .png files get retrieved just fine, since everything else is the same!
I am completely out of things to try. Anyone can help?