帮助:WP7中的隔离存储 [英] Help: Isolated Storage in WP7

查看:69
本文介绍了帮助:WP7中的隔离存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的WP7项目有问题.在我的项目中,我使用XML文件并将其存储在独立存储中.当我关闭我的应用程序并重新启动它时,数据仍然可用,但是当我关闭模拟器并重新打开我的应用程序时,我的所有数据都不再可用.

I have a problem in my WP7 project. In my project,i use XML file and store it in Isolated Storage. when i close my application and restart it, data is still available but when i turn off Emulator and re-open my application, my all data isn''t available any more.

推荐答案

这里的问题是您正在Windows Phone仿真器中运行代码.当您关闭模拟器时,所有保存"到隔离存储中的数据都将消失,因为它不是真实设备.
The issue here is that you are running your code inside the Windows Phone emulator. When you close the emulator, all data that has been "saved" into isolated storage disappears as it is not a real device.


这些问题与隔离存储无关.在这方面,隔离存储的工作方式与常规"文件或文件流完全相同:如果您突然从计算机上断开电源,并且文件未关闭,则结果是不可预测的.要将流更改提交到文件系统,通常使用方法Flush.

这是因为如果使用流缓冲来提高性能.大多数流写入操作都转到缓冲区,而不是立即提交到硬盘驱动器.方法Flush将缓冲区与驱动器上的数据同步.

请参阅:
http://msdn.microsoft.com/en-us/library/system. io.isolatedstorage.isolatedstoragefilestream.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/48cytchs.aspx [ ^ ].

—SA
These issues are not related to isolated storage. In this respect, isolation storage works exactly the same way as a "regular" file or a file stream: if you remove power from a computer suddenly, and the file is not closed, the result is unpredictable. To commit stream changes to the file system, the method Flush is usually used.

This is because if stream bufferization used to improve performance. Most stream write operations go to the buffer and not committed to the hard drive immediately. The method Flush synchronized the buffers with the data on a drive.

Please see:
http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage.isolatedstoragefilestream.aspx[^],
http://msdn.microsoft.com/en-us/library/48cytchs.aspx[^].

—SA


这篇关于帮助:WP7中的隔离存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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