Fixing UnauthorizedAccessException on the Zune
If you come across an "UnauthorizedAccessException" error while programming for your Zune device via XNA the fix is relatively simple. In my case I came across this error when trying to read an XML file on my Zune.
Lets say we have something like,
[code]XDocument doc = XDocument.Load("Content/File.xml");[/code]
This will throw an error on the Zune (and perhaps other devices too) because of how the Zune accesses files locally. To fix we simply change the code to the following,
[code]string path = Path.Combine(StorageContainer.TitleLocation, "Content/File.xml");
XDocument doc = XDocument.Load(path);[/code]
This should resolve the error, if you're still having trouble please post you issues in the comments section below.