Windows Phone 7使用了Silverlight,而在Silverlight中可以使用IsolatedStorage来做独立存储,那么在Windows Phone 7下也可以使用IsolatedStorage 不同程序使用IsolatedStorage存储的数据相互独立,也就是说A程序不能访问B程序通过IsolatedStorage存储的信息,安全性非常高,程序的IsolatedStorage默认为2G大小。
独立设置存储: 命名空间为:System.IO.IsolatedStorage;主要涉及System.IO.IsolatedStorage.IsolatedStorageSettings类。 settings.Clear(); //最终都需要保存 settings.Save(); 独立文件存储: 命名空间为:System.IO.IsolatedStorage ;主要涉及System.IO.IsolatedStorage.IsolatedStorageFile类。 实际上,IsolatedStorage.IsolatedStorageFile类是 FileStream类 的一个子类。 using System.IO.IsolatedStorage; using System.IO; namespace PhoneApp19 { public partial class
但也有一些例外情况,比如 OpenFileDialog 和 IsolatedStorage(存储配额更改),在这种情况下,Silverlight 需要用户的明确同意才能打破沙箱的默认规则集。 OpenFileDialog 用于访问文件系统,而 IsolatedStorage 的作用是访问名义上隔离的存储并提高存储配额。
大致内容回顾: 在使用 IsolatedStorage 的时候应该总是用一个 try..catch (IsolatedStorageException) 块来包装。
可以用来在客户端存储一些数据,我在官方文档上读到这个功能的第一反应就是:用它来做IM的客户端聊天记录存储太棒了,呵呵 这里把官方文档上的示例精减整理了一下,贴在这里纪念 先引用 using System.IO.IsolatedStorage
- 添加特性 同时也为Silverlight添加了必要的特性功能,例如IsolatedStorage等等。
Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Audio; using System.IO.IsolatedStorage
在System.IO.IsolatedStorage命名空间中有一个静态的IsolatedStorageSettings.ApplicationSettings字典(dictionary)。
(可选) 重命名 IsolatedStorage 节点来设置Name 属性。 设置 PartitionName 属性。这标识了缓存管理器将使用的独立存储的区域。
System.IO.IsolatedStorage 包含允许创建和使用独立存储区的类型。
这时要用到System.IO.IsolatedStorage命名空间中的类,这些类允许你的程序在特定用户的目录下将数据写入文件而不需要直接访问硬盘驱动器的权限: // 创建当前用户的独立存储