window phone 独立存储空间System.IO.IsolatedStorage
2012-02-05 12:12
197 查看
window phone 独立存储空间System.IO.IsolatedStorage
window phone中的程序不能随便读取和存储手机中数据,window phone定义了一个专门的机制为每个程序指定特殊的区域来存储读取数据。叫做独立存储
在window phong中System.io下只有IsolatedStorage这个命名空间。
独立存储空间
独立存储空间是一个虚拟的文件系统,每个应用程序只能访问自己的存储空间,不能访问其他的。
独立存储空间又1个或多个独立文件组成,也有文件夹系统。
主要用的方法有两个
1.key/value模式的配置类
System.IO.IsolatedStorage.IsolatedStorageSettings setting = IsolatedStorageSettings.ApplicationSettings;
setting.Add();
setting.Contains();
setting.Remove();
setting.TryGetValue();
setting["key"] = “Value”;
默认情况下IsolatedStorageSettings在应用程序关闭的时候才会写入独立存储空间中,为了防止应用程序意外中断可以使用Save()方法强制写入独立存储空间
2.存储和读取文件模式
IsolatedStorageFile这个类可以用来保存和读取文件, IsolatedStorageFileStream 这个用来读取和写入文件
using(System.IO.IsolatedStorage.IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{}
IsolatedStorageFile.GetUserStoreForApplication()这个方法得到该应用程序对应的用户独立存储空间。
一段代码示例
window phone中的程序不能随便读取和存储手机中数据,window phone定义了一个专门的机制为每个程序指定特殊的区域来存储读取数据。叫做独立存储
在window phong中System.io下只有IsolatedStorage这个命名空间。
独立存储空间
独立存储空间是一个虚拟的文件系统,每个应用程序只能访问自己的存储空间,不能访问其他的。
独立存储空间又1个或多个独立文件组成,也有文件夹系统。
主要用的方法有两个
1.key/value模式的配置类
System.IO.IsolatedStorage.IsolatedStorageSettings setting = IsolatedStorageSettings.ApplicationSettings;
setting.Add();
setting.Contains();
setting.Remove();
setting.TryGetValue();
setting["key"] = “Value”;
默认情况下IsolatedStorageSettings在应用程序关闭的时候才会写入独立存储空间中,为了防止应用程序意外中断可以使用Save()方法强制写入独立存储空间
2.存储和读取文件模式
IsolatedStorageFile这个类可以用来保存和读取文件, IsolatedStorageFileStream 这个用来读取和写入文件
using(System.IO.IsolatedStorage.IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{}
IsolatedStorageFile.GetUserStoreForApplication()这个方法得到该应用程序对应的用户独立存储空间。
一段代码示例
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication()) { WriteableBitmap bmImage = new WriteableBitmap(image); if (!store.DirectoryExists("Images")) { store.CreateDirectory("Images"); } using (IsolatedStorageFileStream isoStream = store.OpenFile(@"Images\userPhoto.jpg", FileMode.OpenOrCreate)) { Extensions.SaveJpeg( bmImage, isoStream, bmImage.PixelWidth, bmImage.PixelHeight, 0, 100); } }
相关文章推荐
- window phone 独立存储空间的操作 推荐
- window phone 独立存储空间的操作
- Windows Phone 7独立存储空间IsolatedStorage
- c# 命名空间之System.IO(继承关系)
- 图片存储架构学习:独立的图片服务器,给爱一个独立的空间
- Windows Phone实用开发技巧(39):WebBrowser引用独立存储空间中的图片
- 图片存储架构学习:独立的图片服务器,给爱一个独立的空间
- System.IO 命名空间
- IIS 异常 “System.OutOfMemoryException”、“存储空间不足,无法完成此操作。”
- C#控制台基础 在查询硬盘的空间是出现system.IO.IOexception
- 友善之臂Mini2440开发板的存储系统及IO空间总结
- SilverLight浏览器交互之:SilverLight用户独立存储空间的计算和扩展
- System.IO 命名空间
- 表数据和索引数据分开独立表空间存储优点
- windows phone 独立存储空间的操作 (2)
- windows phone7 学习笔记09——隔离存储空间(IsolatedStorage)
- WP8用户独立存储空间中文件的创建和读取
- Windows Phone 7(WP7)开发工具 查看独立存储空间中数据库内容
- wp7 独立存储空间在真机和虚拟机测试的时候数据不一样
- windows phone 独立存储空间的操作 (2)