Hello
I’ve been browsing the forums and everywhere to be honest, but with no lucky, at least not with recent posts (2008+).
I am developing an App that is designed to read a XML in a web server and check for its contents. By reading the XML, the App should know which images it should download to display (it is like a dynamic catalog). My idea was, create a Web interface for my client to update the XML and upload the new images, and access the XML thru the WWW class. Then, check if the web XML is different from the local XML (if it exists), overwrite the local XML, and download the required images, if they dont exist also. I need to store these files in a more permanent way, so that if they close the App, they are still there.
My first try was with the System.IO.File class… and it does work perfectly on my machine, but as soon as I try it running on the iPad, it doesnt work.
Here is my code, its very simple:
//To select the correct location
docPath = Application.dataPath;
if(Application.platform == RuntimePlatform.IPhonePlayer)
{
docPath = docPath.Substring(0, docPath.Length - 5);
docPath = docPath.Substring(0, docPath.LastIndexOf('/')) + "/Documents";
}
StartCoroutine(ReadXML(docPath + "/fila-info.xml", 3));
And the read/write code is:
private IEnumerator ReadXML(string file, float waitTime)
{
yield return new WaitForSeconds(waitTime);
WWW tempWWW = new WWW(GlobalValues.domainAddress + "/file.xml");
yield return tempWWW;
FileInfo info = new FileInfo(file);
if(info != null || info.Exists != false)
{
if (!File.ReadAllText(file).Equals(tempWWW.text))
{
File.WriteAllText(file, tempWWW.text);
}
else
{
}
}
else
{
}
}
Problem is, it does not process the File.WriteAllText or ReadAllText, and I was using File.Exists instead of FileInfo… I am “using System.IO”… It seens to me as if this was incompatible… but if I am doing something wrong, please tell me.
Thank you for your time,
Allan