Hi, can somebody help me here? I'm using the ContactPicker to select some contacts which I want to save the to xml file. I'm doing this.
public async Task SaveSelectedContacts()
{
StorageFolder folder = ApplicationData.Current.LocalFolder;
IStorageFile contactsFile;
contactsFile = await folder.CreateFileAsync("SavedContacts.xml", CreationCollisionOption.ReplaceExisting);
using (IRandomAccessStream stream= await contactsFile.OpenAsync(FileAccessMode.ReadWrite))
using (Stream outputStream=stream.AsStreamForWrite())
{
DataContractSerializer serializer=new DataContractSerializer(typeof(ObservableCollection<Contact>));
serializer.WriteObject(outputStream, ContactsList);
}
}
That way I get this exemption "An exception of type 'System.Runtime.Serialization.InvalidDataContractException' occurred in mscorlib.dll but was not handled in user code". So any ideas how can I serialise the contactsFile and save it to a xml file?
Thank in advance.