I would like to save and read the xml file. But the path is always incorrect. Who can help me?
If I direct access to the path, then the : / xxxx-xxx-xxx/data/filename.xml
The real path is: : / xxxx-xxx-xxx/appname.app/data/filename.xml
I am programming problem, or bug?
string root = Application.dataPath.Substring(0, Application.dataPath.Length - 4) + "Documents";
if (System.IO.Directory.Exists(root))
{
return root; // for phone
}
else
{
return ""; // for development on PC (not phone)
}
Does anyone know a way to get the name of the app (in code), so the appropriate number of characters can be removed from the Application.dataPath string?
If you have iPhone Advanced using ObjC is much faster and especially future proof cause it does not depend on apple not messing with the structure.
The following function for example returns the path to the cache dir which is what you commonly want to use (not documents - cause cache is not backed up in itunes. you would use this for downloadable levels etc):