File Corrupt after Pwr Crash

I am trying to create a file that keeps status on my application and would provide a way to recover if the app hung or there was a power outage/crash. I was implementing a ping/pong type system where i have two files, (ping and pong), and write to them alternately. I was hoping that by doing this i would always have one "in the bank" ie on disk and safe. It turns out that so far i cannot show this. I have tried a few different things but when i turn the power off, (in the middle of running my app), and then boot back up into windows, both the ping and pong file can be corrupted. I guess the bottom line is this: is there anyway to be sure the file is written to disk, (in the bank), before i start to write to the other file. Even though i do a "close" on the files before writing to the other, they both still seemed to be cached somehow and not getting completely written. BTW this is using C# on windows XP SP3. I am also not sure the best place to post this.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion