windows phone 独立存储空间的操作 (2)
2012-03-25 12:29
369 查看
IsolatedStorage独立存储空间是保存应用程序的一些数据已经配置文件,独立存储空间相对于其他的wp程序是独立的,也就是说每个wp程序都会有自己的独立存储空间,每个wp程序相互之间不能访问;
View Code /// <summary>
/// 读操作
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnRead_Click(object sender, RoutedEventArgs e)
{
IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication();
if (isStore.FileExists("test\\TEST.txt"))
{
IsolatedStorageFileStream isStream = new IsolatedStorageFileStream("test\\TEST.txt", System.IO.FileMode.Open, FileAccess.Read, isStore);
//获取路径
string[] directoryName = isStore.GetDirectoryNames("test");
//获取文件名 搜索模式。 单字符("?")和多字符("*")通配符都受支持
string[] fileName = isStore.GetFileNames("test\\T*.txt");
txtShow.Text = "写入资料值为:" + isStream.ReadByte().ToString() + ";\n路径为:" + directoryName[0].ToString() + ";\n文件名称为:" + fileName[0];
isStream.Close();
isStore.Dispose();
txtShow.Text =txtShow.Text+ "\n读取完成";
//存储配置信息
var settings = IsolatedStorageSettings.ApplicationSettings;
//判断key 是否存在
if (settings.Contains("ip"))
{
//只支持key的查询
string ip = settings["ip"].ToString();
//out传参获取值
string ipStr;
settings.TryGetValue("ip", out ipStr);
txtShow.Text = txtShow.Text + "\n配置文件ip:" + ip + ";\n out传参ip:"+ipStr;
}
}
}
读取效果
什么是Isolated Storage?
Isolated Storage又叫做隔离存储空间,Windows Phone 7手机上用来本地存储数据。下图是一个存储应用的文件夹结构图:View Code /// <summary>
/// 读操作
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnRead_Click(object sender, RoutedEventArgs e)
{
IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication();
if (isStore.FileExists("test\\TEST.txt"))
{
IsolatedStorageFileStream isStream = new IsolatedStorageFileStream("test\\TEST.txt", System.IO.FileMode.Open, FileAccess.Read, isStore);
//获取路径
string[] directoryName = isStore.GetDirectoryNames("test");
//获取文件名 搜索模式。 单字符("?")和多字符("*")通配符都受支持
string[] fileName = isStore.GetFileNames("test\\T*.txt");
txtShow.Text = "写入资料值为:" + isStream.ReadByte().ToString() + ";\n路径为:" + directoryName[0].ToString() + ";\n文件名称为:" + fileName[0];
isStream.Close();
isStore.Dispose();
txtShow.Text =txtShow.Text+ "\n读取完成";
//存储配置信息
var settings = IsolatedStorageSettings.ApplicationSettings;
//判断key 是否存在
if (settings.Contains("ip"))
{
//只支持key的查询
string ip = settings["ip"].ToString();
//out传参获取值
string ipStr;
settings.TryGetValue("ip", out ipStr);
txtShow.Text = txtShow.Text + "\n配置文件ip:" + ip + ";\n out传参ip:"+ipStr;
}
}
}
读取效果
相关文章推荐
- windows phone 独立存储空间的操作
- windows phone 独立存储空间的操作(2)[转]
- windows phone 独立存储空间的操作 (2)
- windows phone 独立存储空间的操作 (2)
- Windows Phone 7程序独立存储空间容量测试
- Windows Phone 隔离存储空间及文件操作
- Windows Phone 7 隔离存储空间及文件操作
- window phone 独立存储空间的操作
- window phone 独立存储空间的操作 推荐
- Windows Phone 7独立存储空间IsolatedStorage
- Windows Phone实用开发技巧(39):WebBrowser引用独立存储空间中的图片
- Windows Phone 7(WP7)开发工具 查看独立存储空间中数据库内容
- silverlight 独立存储之路径、保存图片、扩展空间注意事项
- Windows Phone 7 独立存储使用XML文件来存储信息
- SQL Server CE:没有足够的存储空间来完成该操作[CODE:8007000E]
- IE6 错误53存储空间不足,无法完成此操作,解决方法
- window phone 独立存储空间System.IO.IsolatedStorage
- Windows Phone 7 独立存储使用XML文件来存储信息
- windows phone 8 异步访问独立存储区
- Windows Phone开发之独立存储、文件的读写、ListBox绑定数据、NavigationService实现XAML跳转