TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Manoj Maharana
NA
362
128.5k
how to save data in xml using windows 8.1 mobile app
Aug 12 2016 6:57 AM
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<ClsOrder> ordlist = await getXmlorderlist();
ordlist.Add(ord);
using (var stream = await ApplicationData.Current.LocalFolder.OpenStreamForWriteAsync(XmlFile, CreationCollisionOption.ReplaceExisting))
{
var serializer = new DataContractSerializer(typeof(List<ClsOrder>));
serializer.WriteObject(stream, ordlist);
}
}
private async Task<List<ClsOrder>> getXmlorderlist()
{
await ApplicationData.Current.LocalFolder.CreateFileAsync(XmlFile, CreationCollisionOption.OpenIfExists);
var stream = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync(XmlFile);
if (stream.Length == 0)
return new List<ClsOrder>();
DataContractSerializer serializer = new DataContractSerializer(typeof(List<ClsOrder>));
List<ClsOrder> ordlist = (List<ClsOrder>)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<ClsOrder> ordlist,I want to save data in xml.
Reply
Answers (
2
)
Windows 7 Task Scheduler
Download and extract zip files