The following question is not a typical programming question, but IMHO programmers are affected by this and are most likely to have a solution.
I have a Windows desktop application that communicates with a server. The client app has an optional "offline mode" feature (primarily for laptops), which works by serializing DTOs locally until a user returns to his LAN. The DTOs are serialized to encrypted XML files which are written whenever the data changes (writtend to the user's [AppData]/AppName dir).
The problem is that some of the users tend to leave the application open and close the laptop until it eventually runs out of battery, and when they return to the office the XML files don't exist anywhere on the laptop's disk.
I've combed the code countless times, implemented various writer/stream flushes, file-existence/timestamp checks after the file is written, etc. and it's still happening. The only thing I can think of is windows write-caching, which is enabled by default on XP, Vista and 7. Is it known that it can cause problems of this kind and how can I prevent them in my app (short of forcing the users to turn off write caching globally)?
I've found Sysinternals Sync which seems like it does disk-cache flushing, but it requires admin privileges which my users don't have.