如何在文本文件上写入并使其持久化 [英] How to write on text file and make it persistent

查看:72
本文介绍了如何在文本文件上写入并使其持久化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

b $ b我的WinCE应用程序从通过套接字连接的外部设备获取数据,并每秒将其写入文本文件。

每30次收购我刷新并关闭文件流以使其持久以避免电源与设备断开连接时的情况。

Hi,
my WinCE application acquire data from an external device connected via socket and write it to a text file every second.
Every 30 acquisitions I flush and close the File Stream to make it persistent to avoid situation when the power supply is disconnected from the device.

不幸的是,这不会发生。当设备严重关闭时,我的文件只包含几行而不是数百行。

相反,如果应用程序正常关闭,则文件正常。

Unfortunately this not happen. When the device is switched off sharply, my file contains only few lines instead of hundreds.
Instead if the application is closed normally, the file is ok.

我该如何解决这种情况?

How can I solve this situation?

问候,

Daniele。

Regards,
Daniele.

推荐答案

如果在设备关闭时没有关闭文件。档案中没有记录。
If you did not close the file when the device turn off. There will be not records in file.


这篇关于如何在文本文件上写入并使其持久化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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