Windows Phone 有关独立存储(一)
private const string foldername = "temp1";
private const string filename = foldername + "/address.txt";
private const string settingname = "sname";
1.创建文件夹
private void button1_Click(object sender, RoutedEventArgs e)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
file.CreateDirectory(foldername);
}
}
2.检查文件夹是否存在
private void button2_Click(object sender, RoutedEventArgs e)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
if (file.DirectoryExists(foldername))
{
MessageBox.Show("已存在");
}
else
{
MessageBox.Show("不存在");
}
}
}
3.删除目录
private void button3_Click(object sender, RoutedEventArgs e)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
file.DeleteDirectory(foldername);
}
}
4.创建文件
private void button4_Click(object sender, RoutedEventArgs e)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
IsolatedStorageFileStream stream = file.CreateFile(filename);
stream.Close();
}
}
5.检查文件是否存在
private void button5_Click(object sender, RoutedEventArgs e)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
if (file.FileExists(filename))
{
MessageBox.Show("已存在" + filename);
}
else
{
MessageBox.Show("不存在");
}
}
}
6.删除文件
private void button6_Click(object sender, RoutedEventArgs e)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
file.DeleteFile(filename);
}
}
7.向文件中增加内容
private void button7_Click(object sender, RoutedEventArgs e)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = file.OpenFile(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
StreamWriter writer = new StreamWriter(stream);
writer.WriteLine(textBox1.Text);
writer.Close();
textBox1.Text = "";
}
}
}
8.读取文件内容
private void button8_Click(object sender, RoutedEventArgs e)
{
using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream stream = file.OpenFile(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
using (StreamReader reader=new StreamReader (stream))
{
textBox1.Text = reader.ReadToEnd();
}
} }
}
9、程序配置信息保存
private void button9_Click(object sender, RoutedEventArgs e)
{
IsolatedStorageSettings.ApplicationSettings[settingname] = textBox2.Text;
IsolatedStorageSettings.ApplicationSettings.Save();
textBox2.Text = "";
}
10.程序配置信息读取
private void button10_Click(object sender, RoutedEventArgs e)
{
if (IsolatedStorageSettings.ApplicationSettings.Contains(settingname))
{
textBox2.Text = IsolatedStorageSettings.ApplicationSettings[settingname].ToString();
}
}
Windows Phone 有关独立存储(一)的更多相关文章
- Windows phone 之独立存储
独立存储命名空间的说明:
- 与众不同 windows phone (6) - Isolated Storage(独立存储)
原文:与众不同 windows phone (6) - Isolated Storage(独立存储) [索引页][源码下载] 与众不同 windows phone (6) - Isolated Sto ...
- Windows Phone 独立存储资源管理器工具
如何使用独立存储资源管理器工具 http://msdn.microsoft.com/zh-CN/library/hh286408(v=vs.92)C:\Program Files (x86)\Micr ...
- Windows Phone 独立存储查看器
1.为了查看我们存放在独立存储的数据,我们需要借助独立存储查看器. 2.简单介绍下,IsoStoreSpy 下载地址:http://download.csdn.net/download/lhb1097 ...
- win10的独立存储
win10的独立存储和win8的大致相同 Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.Appl ...
- Silverlight-管理独立存储(Isolated Storage)
Silverlight中的独立存储是其内部的可信任的可访问文件空间,在这里你可以使用Silverlight 随意的创建.读取.写入.删除目录和文件,它有一些类似于Cookie,但是它可以在客户端保存大 ...
- WP8 独立存储 总结3(应用设置)
•可在独立存储中使用ApplicationSettings对象•在独立存储中存储键/值对的Dictionary方式存储 •存储的对象将永久保存 在应用设置中保存数据 void saveString(s ...
- WP_从独立存储区读取缓存的图片
///<summary> /// 独立存储缓存的图片源 /// 用法:item.img = new StorageCachedImage(newUri(http://www.baidu ...
- Silverlight 独立存储(IsolatedStorageFile)
1.在Web中添加天气服务引用地址 http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl 2.在Web中添加Wcf服务接口I ...
随机推荐
- EcmaScript对象克隆之谜
先谈谈深拷贝 如何在js中获得一个克隆对象,可以说是喜闻乐见的话题了.相信大家都了解引用类型与基本类型,也都知道有种叫做深拷贝的东西,传说深拷贝可以获得一个克隆对象!那么像我这样的萌新自然就去学习了一 ...
- HTML(二):表格元素
表格元素的作用:用来格式化显示数据. 一.表格的基本结构 表格的基本语法:<TABLE border="设置表格边框尺寸大小" width="" cell ...
- Golang map 如何进行删除操作?
Cyeam 关注 2017.11.02 10:02* 字数 372 阅读 2784评论 0喜欢 3 map 的删除操作 Golang 内置了哈希表,总体上是使用哈希链表实现的,如果出现哈希冲突,就把冲 ...
- Convolution Network及其变种(反卷积、扩展卷积、因果卷积、图卷积)
今天,主要和大家分享一下最近研究的卷积网络和它的一些变种. 首先,介绍一下基础的卷积网络. 通过PPT上的这个经典的动态图片可以很好的理解卷积的过程.图中蓝色的大矩阵是我们的输入,黄色的小矩阵是卷积核 ...
- css -- 通俗理解inline、block、inline-block
display:inline; 内联元素,简单来说就是在同一行显示. display:block; 块级元素,简单来说就是就是有换行,会换到第二行. display:inline-block; 就是在 ...
- 基于Poco的UTF8、UTF16、GBK、Hex之间的转换
/******Encoding.h*******/ #include "Poco/UnicodeConverter.h" #include "Poco/Exception ...
- php 输出带变量字符串(echo 函数的应用)
转自: http://www.cnblogs.com/devcjq/articles/2306150.html 学习PHP从最简单的开始:echo, print<?php$temp = arr ...
- Java线程之Callable和Future
本篇说明的是Callable和Future,它俩很有意思的,一个产生结果,一个拿到结果. Callable接口类似于Runnable,从名字就可以看出来了,但是Runnable不会返回结 ...
- sourcetree管理git
下载地址: https://www.sourcetreeapp.com/ 跳过注册: 到注册登录页面打开文件目录%LocalAppData%\Atlassian\SourceTree\ 会发现有个文件 ...
- 性能测试指标的理解--cpu和load
第一次做性能测试,按照操作文档磕磕碰碰的完成了,并且拿到了结果,看到一堆的指标和数据,还是傻眼了,不知道各个指标是什么意思了. 咨询了大牛和度娘,消化理解了一下,不知道是不是正确的. CPU使用率: ...