Windows Phone的本地存储——IsolatedStorageFile
2012-02-21 20:29
369 查看
本篇我们来了解如何通过IsolatedStorageFile来实现信息的本地存储。使用IsolatedStorageFile和使用System.IO.File和System.IO.Directory进行文件访问非常类似,再此仅仅列出对于文本文件的写入跟读取。
通过IsolatedStorageFile写入文件:
通过IsolatedStorageFile读取文件:
通过IsolatedStorageFile写入文件:
private void WriteData() { IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication(); store.CreateDirectory("StoreFileTemp"); using (IsolatedStorageFileStream storeStream = new IsolatedStorageFileStream("StoreFileTemp\\Test.txt", FileMode.OpenOrCreate, store)) { using (StreamWriter sw = new StreamWriter(storeStream)) { sw.WriteLine(txtWrite.Text); } } }
通过IsolatedStorageFile读取文件:
private void ReadData() { IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication(); if (store.FileExists("StoreFileTemp\\Test.txt")) { using (IsolatedStorageFileStream storeStream = new IsolatedStorageFileStream("StoreFileTemp\\Test.txt", FileMode.Open, store)) { using (StreamReader sr = new StreamReader(storeStream)) { tbRead.Text = sr.ReadLine(); } } } }
相关文章推荐
- Windows Phone的本地存储——IsolatedStorageFile
- Windows Phone 7的本地存储——IsolatedStorageSettings
- Windows Phone的本地存储——IsolatedStorageSettings
- Windows Phone的本地存储——IsolatedStorageSettings
- 独立存储, windows phone IsolatedStorageFile
- WP7独立存储之IsolatedStorageFile之图片的存储和读取
- 使用 IsolatedStorageFileStream 存储信息
- 使用 IsolatedStorageFileStream 存储信息
- 利用WP7独立存储IsolatedStorageFile读写文件
- IsolatedStorageFile 本地数据缓存 xml dataset 读写
- 关于Windows phone 7.1 IsolatedStorageFile问题
- Windows phone 7中,把页面数据存为长期存储(非IsolatedStorageFile),而是用IsolatedStorageSettings
- Windows Phone 独立存储(IsolatedStorageFile)
- 线程本地存储TLS(Thread Local Storage)的原理和实现——分类和原理
- React Native AsyncStorage本地存储工具类
- Windows Phone 独立存储之IsolatedStorageFile
- 线程本地存储TLS(Thread Local Storage)的原理和实现——分类和原理
- html5客户端本地存储之sessionStorage及storage事件
- HTML5 和 Cocos2d-js 的cc.sys.localStorage本地存储到哪里了?
- HTML5本地存储 -sessionStorage localStorage 总结