- Home /
XML Load unauthorized access
Hi,
I'm using a modified version of the script found on this site to save and load xml data to a file.
http://unifycommunity.com/wiki/index.php?title=Save_and_Load_from_XML
It writes the xml file just fine, but when I got to load it, I get this error.
"UnauthorizedAccessException: Access to the path '\' is denied."
This is not a networked project, it's all local. I'm not sure why access is denied. If anyone could help that would be great.
Answer by $$anonymous$$ · Dec 11, 2012 at 07:57 PM
For anyone that has this problem, try verifying that you access the correct file, so the path that you the streamreader is a correct one. The best way, for me, is
StreamReader streamReader = new StreamReader(Application.persistentDataPath + "/" + "filename");
This if for c#. the string filename should be exactly the name of the file you need to access. Application.persistanceDataPath is the path where your application saves a xml file if you create one on your own. To verify it's value just write print(Application.persistentDataPath); and it will write in the console were to go if you want to edit that xml file manually