I have used the below function present on this page
public static void WriteToXmlFile<T>(string filePath, T objectToWrite, bool append = false) where T : new()
{
TextWriter writer = null;
try
{
var serializer = new XmlSerializer(typeof(T));
writer = new StreamWriter(filePath, append);
serializer.Serialize(writer, objectToWrite);
}
finally
{
if (writer != null)
writer.Close();
}
}
I am calling it using:
WriteToXmlFile<List<channel>>("channels.txt", channelList);
This is in order to save a list of tv channels to a local file so it could be reopened later to dispaly it to the user.
This worked perfectly when i was testing : i was uninstalling any previous version on the phone, doing a clean build then doing a deployment on the phone, and then starting the application on the phone directly.
Then i downloaded the application from the Store and the saving is not happening anymore (i have no errors as i caught all exceptions).
May i know why the list is not saved anymore with the published version ? Am i missing any capabilities ? Or is the file path (actually i provide none) or the method i am using to save the file not the right one ?
I could read something about Isolated Storage, should i use this ?
My application is for Windows Phone 8.x and higher
The file is just to be used by the application
There are max 10 items to put in the file so the saving should be quick (no heavy requirement on async saving method)
Thank you
I used the IsolatedStorage instead (there are samples on this website too) and my problem is gone.
I don't really know where the method i was using was putting the file but it was definitely not the proper way to do it.