I am serializing a file in Windows 8.1 preview and I believe the behavior of the storage file class has changed.
Before when I used CreationCollisionOption.ReplaceExisting the serialization would "replace" the existing file with data from the new serialization. Now nothing gets serialized, so the "existing" file now gets replaced with a 0 byte file. The way I read ReplaceExisting is if the file exists, replace it with a new one.
OpenIfExists actually writes data to the file.
public static async Task SerializeObjectToFileAsync<T>(T objectToSerialize, string fileName ) { StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting); var serializer = new DataContractSerializer(typeof(T)); using (IRandomAccessStream raStream1 = await file.OpenAsync(FileAccessMode.ReadWrite)) { serializer.WriteObject(raStream1.AsStream(), objectToSerialize); } }