when i click save button data is not saving in xml file
Here is the code:
private const string XmlFile = "Order.xml";
private async void btncalculate_Click(object sender, RoutedEventArgs e)
{
ClsOrder ord = new ClsOrder();
ord.Id = 1;
ord.package = str;
ord.Domestic = strchk;
List ordlist = await getXmlorderlist();
ordlist.Add(ord);
using (var stream = await ApplicationData.Current.LocalFolder.OpenStreamForWriteAsync(XmlFile, CreationCollisionOption.ReplaceExisting))
{
var serializer = new DataContractSerializer(typeof(List));
serializer.WriteObject(stream, ordlist);
}
}
private async Task
- > getXmlorderlist()
{
await ApplicationData.Current.LocalFolder.CreateFileAsync(XmlFile, CreationCollisionOption.OpenIfExists);
var stream = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync(XmlFile);
if (stream.Length == 0)
return new List();
DataContractSerializer serializer = new DataContractSerializer(typeof(List));
List ordlist = (List)serializer.ReadObject(stream);
return ordlist;
}
How to save data in xml file.?? This code is not working.. I have taken all the data in list List ordlist,I want to save data in xml.
Gokhul VarmanPosted Jul 26, 2017, 8:36 AM
Santhakumar MunuswamyPosted Aug 12, 2016, 10:50 AM
http://www.codeproject.com/Articles/758657/Easy-Ways-to-Store-Data-Locally-in-a-Windows-Phone