I'm working on a Windows 8.1 XAML/C# Metro app.
Currently, I am getting an authorization error when trying to save an XML document. Here is the method that when run throws:
public async void saveXML(string fileName)
{
Windows.Storage.StorageFolder sf = await Windows.ApplicationModel.Package.Current.InstalledLocation.CreateFolderAsync("XML");
StorageFile st = await sf.CreateFileAsync(fileName);
await SyncXMLDoc.SaveToFileAsync(st);
}
Here is the specific error:
How do I resolve this? Why would I not be allowed to create an XML file?
You can not write files to the application's install directory. From the File access and permissions article on MSDN:
The app's install directory is a read-only location.
You have to save your files to one of the Application Data Folders, also explained in that article.