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();
}
}

最新文章

  1. Spring基础——在 Spring Config 文件中基于 XML 的 Bean 的自动装配
  2. dispatch_async & dispatch_sync
  3. Mongodb与关系型数据库
  4. python笔记之itertools模块
  5. java图形
  6. Jsp——http status 404 问题
  7. Redis 小白指南(二)- 基础命令和五大类型:字符串、散列、列表、集合和有序集合
  8. 自学Aruba2.3-Aruba Web UI --Configuration面板介绍
  9. 类型和原生函数及类型转换(二:终结js类型判断)
  10. python输出
  11. C语言典型编程1
  12. C#—ASP.NET:集成极光推送(Push API v3)
  13. [洛谷日报第62期]Splay简易教程 (转载)
  14. angular default project (angular.json的解读)
  15. pseudo tty破除无法自动输入密码的限制
  16. 表结构变更后出现的ERROR OGG-01161 Bad column index (88)
  17. OKR 说明
  18. ul>li中自定义属性后取值的问题
  19. 一起做RGB-D SLAM (3)
  20. attributes["wv"].nodeValue

热门文章

  1. 有趣的 Mysql 存储引擎
  2. 05 Oracle process
  3. e666. 创建缓冲图像
  4. Zookeeper leader选举
  5. Kubernetes(一)初探
  6. Python 爬虫批量下载美剧 from 人人影视 HR-HDTV
  7. [LeetCode] Subsets II [32]
  8. 【转】如何读懂Oracle文档中的语法图
  9. 【R markdown】rmysql乱码问题
  10. ChemDraw Std 14如何标记同位素