I am currently developing a Windows 8.1 Application using C# and XAML in which I store a huge amount of data using XML format in the local cache of the application. I am getting the following error with one of the XML files out of three since the other two are being created: "Error:There was an error generating the XML document." Below is my code:
if (!string.IsNullOrEmpty(localData2))
{
StorageFile localFile = await ApplicationData.Current.LocalFolder
.CreateFileAsync("LocalCache2.xml", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(localFile,
ObjectSerializer<ObservableCollection<aceapp.Competitor>>.ToXml(cacheXML2));
}
if (!string.IsNullOrEmpty(localData3))
{
StorageFile localFile = await ApplicationData.Current.LocalFolder
.CreateFileAsync("LocalCache3.xml", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(localFile,
ObjectSerializer<ObservableCollection<aceapp.Attributes>>.ToXml(cacheXML3));
}
if (!string.IsNullOrEmpty(localData))
{
MemoryStream stream = new MemoryStream();
StorageFile localFile = await ApplicationData.Current.LocalFolder
.CreateFileAsync("LocalCache1.xml", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(localFile,
ObjectSerializer<ObservableCollection<aceapp.Sector>>.ToXml(cacheXML1));
}
The Error is with the last XML which is the largest one. Any idea about this issue and how to fix it?