Pwr崩溃后文件损坏 [英] File Corrupt after Pwr Crash

查看:82
本文介绍了Pwr崩溃后文件损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试创建一个文件,该文件在我的应用程序中保持状态,并提供一种方法来恢复该应用程序挂起或断电/崩溃的情况.我正在实现一个ping/pong类型的系统,其中有两个文件(ping和pong),并交替写入它们.我希望通过这样做,我将始终拥有一个在银行"账户.即在磁盘上,安全.事实证明,到目前为止,我还不能显示这一点.我尝试了几种不同的方法,但是当我关闭电源(在运行应用程序的过程中),然后重新启动进入Windows时,ping和pong文件都可能损坏.我想最重要的是:在我开始写入另一个文件之前,是否要确保已将文件写入磁盘(在存储区中).即使我进行关闭"操作,在将文件写入另一个文件之前,它们似乎都仍以某种方式被缓存并且没有被完全写入.顺便说一句,这是在Windows XP SP3上使用C#.我也不确定发布此内容的最佳位置.
谢谢

Hi,
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.
Thanks

推荐答案

请参阅
See this[^] thread to see if it helps.


这篇关于Pwr崩溃后文件损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆