windows phone 独立存储空间的操作 (2)
2014-03-05 14:44
399 查看
原文:windows phone 独立存储空间的操作 (2)
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;
}
}
}
读取效果
IsolatedStorage独立存储空间是保存应用程序的一些数据已经配置文件,独立存储空间相对于其他的wp程序是独立的,也就是说每个wp程序都会有自己的独立存储空间,每个wp程序相互之间不能访问;
什么是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 独立存储空间的操作 (2)
- windows phone 独立存储空间的操作
- windows phone 独立存储空间的操作(2)[转]
- windows phone 独立存储空间的操作 (2)
- Windows Phone 7(WP7)开发工具 查看独立存储空间中数据库内容
- Windows Phone 7程序独立存储空间容量测试
- Windows Phone 7 隔离存储空间及文件操作
- Windows Phone 隔离存储空间及文件操作
- window phone 独立存储空间的操作
- window phone 独立存储空间的操作 推荐
- Windows Phone 7独立存储空间IsolatedStorage
- Windows Phone实用开发技巧(39):WebBrowser引用独立存储空间中的图片
- PostgreSql 使用postgis 存储地理空间信息操作以及jsonb操作示例
- VS编译出现将元数据写入文件“x:/x/obj/Debug/xx.exe”时发生错误 --“存储空间不足,无法完成此操作。 ”
- 图片存储架构学习:独立的图片服务器,给爱一个独立的空间
- Windows Phone 独立存储之IsolatedStorageFile
- 表数据和索引数据分开独立表空间存储优点
- VS2010 提示存储空间不足 无法操作
- Windows Phone 7 隔离存储空间资源管理器
- 针对 Windows Phone 7 上的独立存储的 Sterling