How can I serialize objects in a UWP application? This is my code:
Car bmw = new Car() { Make = "BMW", Model = "X5" };
XmlSerializer serializer = new XmlSerializer(typeof(Car));
using (Stream stream = new FileStream(@"XMLTEST.txt", FileMode.Append, FileAccess.Write))
{
serializer.Serialize(stream, bmw);
}
It generates an exception:
System.UnauthorizedAccessException: 'Access to the path 'C:\Users\annou\onedrive\documents\visual studio 2017\Projects\Hamburger6\Hamburger6\bin\x86\Debug\AppX\XMLTEST.txt' is denied.'
I do the same in a Console app and it works. Why isn't it working in UWP the way it does in a Console app?