made a Mindmapping app for UWP some month ago.
The file handling is managed by the app:
- The files are auto saved
- The files are stored in the LocalFolder
- I use a queue for all file operations (See code)
The files are saved transactional, see the following snippet
using (StorageStreamTransaction transaction = await file.OpenTransactedWriteAsync()) { JsonDocumentSerializer.Serialize(history, transaction.Stream.AsStreamForWrite()); await transaction.CommitAsync(); }
JsonDocumentSerializer is just a wrapper around JsonSerializer.
From time to time I get some bug reports from users, that the file gets corrupt, e.g. the file seems to have to correct size but is just empty or the only have the json is written to the file.
How can this happen?