博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Windows Phones 7 文件操作
阅读量:6930 次
发布时间:2019-06-27

本文共 4026 字,大约阅读时间需要 13 分钟。

Windows Phones 文件操作,自己重新测试了一遍,通过,给大家参考使用。

     private const string foldername = "xu";        private const string filename = "info.txt";        private const string filepath = foldername +"/"+ filename;        private const string settingname = "sname";        ///         /// 创建文件夹        ///         ///         ///         private void button1_Click(object sender, RoutedEventArgs e)        {            using (IsolatedStorageFile file=IsolatedStorageFile.GetUserStoreForApplication())            {                file.CreateDirectory(foldername);            }        }      //检查文件夹是否存在        private void button2_Click(object sender, RoutedEventArgs e)        {            using (IsolatedStorageFile file=IsolatedStorageFile.GetUserStoreForApplication())            {                if (file.DirectoryExists(foldername))                {                    MessageBox.Show("存在"+foldername);                }                else                {                    MessageBox.Show("不存在");                }            }        }        //删除文件夹        private void button3_Click(object sender, RoutedEventArgs e)        {            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())            {                file.DeleteDirectory(foldername);            }        }        //创建文件        private void button6_Click(object sender, RoutedEventArgs e)        {            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())            {              IsolatedStorageFileStream sd= file.CreateFile(filepath);        //一定要记得关闭 不然有bug              sd.Close();            }        }        //判断文件是否存在        private void button4_Click(object sender, RoutedEventArgs e)        {            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())            {                if (file.FileExists(filepath))                {                    MessageBox.Show("存在"+filepath);                }                else                {                    MessageBox.Show("不存在");                }            }        }        //删除文件操作        private void button5_Click(object sender, RoutedEventArgs e)        {            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())            {                file.DeleteFile(filepath);            }        }        //在文件里增加内容        private void button7_Click(object sender, RoutedEventArgs e)        {            using (IsolatedStorageFile file=IsolatedStorageFile.GetUserStoreForApplication())            {                using (IsolatedStorageFileStream fs=file.OpenFile(filepath,FileMode.OpenOrCreate,FileAccess.Write))                {                    using (StreamWriter sw = new StreamWriter(fs))                    {                        sw.WriteLine("我爱你");                    }                 }            }        }        //读取文件内容        private void button8_Click(object sender, RoutedEventArgs e)        {            using (IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication())            {                using (IsolatedStorageFileStream fs = file.OpenFile(filepath, System.IO.FileMode.OpenOrCreate, FileAccess.Read))                {                    using (StreamReader sr=new StreamReader(fs))                    {                        MessageBox.Show(sr.ReadToEnd());                    }                }            }        }        //保存信息配置信息        private void button9_Click(object sender, RoutedEventArgs e)        {            IsolatedStorageSettings.ApplicationSettings[settingname] = "哈哈";            IsolatedStorageSettings.ApplicationSettings.Save();            MessageBox.Show("保存成功");        }        //读取程序配置信息        private void button10_Click(object sender, RoutedEventArgs e)        {            if (IsolatedStorageSettings.ApplicationSettings.Contains(settingname))            {                MessageBox.Show(IsolatedStorageSettings.ApplicationSettings[settingname].ToString());            }        }

 

转载地址:http://eumjl.baihongyu.com/

你可能感兴趣的文章
博科:物理与虚拟网络的统一管理
查看>>
(转)TMG2010 日志队列
查看>>
桐庐县第一人民医院数据库容灾备份系统项目-存储网关
查看>>
android.os.NetworkOnMainThreadException
查看>>
Java基本语法(四)数组
查看>>
ocjp 91-100
查看>>
虚拟化用户***率不断提升 应用加速转化端到端
查看>>
图说:轻松让Windows 8有个印象中的“开始菜单”
查看>>
洛谷——P3387 【模板】缩点
查看>>
我的友情链接
查看>>
编程者的修仙之路
查看>>
使用IPSec虚拟隧道接口建立IPSec安全隧道
查看>>
洛谷—— P3372 【模板】线段树 1
查看>>
DHCP
查看>>
shell 执行curl传post 数据中的变量
查看>>
Zookeeper工作原理
查看>>
我的友情链接
查看>>
Point-to-Point (p2p) GRE over IPsec
查看>>
分布式助手Zookeeper(三)
查看>>
我的友情链接
查看>>