小猪

导航

WP7 隔离存储空间 创建文件 读取文件内容

using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
    //判断文件是否存在
    if (!isf.FileExists(Used.strKeyPath))
    {
      //创建文件夹
      isf.CreateDirectory(Used.strMainPath);
      //创建注册文件
      StreamWriter writerKey = new StreamWriter(new IsolatedStorageFileStream(Used.strSignInPath, FileMode.OpenOrCreate, isf));
      writerKey.WriteLine("1");
      writerKey.Close();
      }

      //读取文件内容
      if (!isf.DirectoryExists(Used.strSignInPath))
      {
         StreamReader reader = new StreamReader(new IsolatedStorageFileStream(Used.strSignInPath, FileMode.Open, isf));
         Used.strSignIn = reader.ReadLine();
      }
 }

 

posted on 2012-02-23 10:09  ~小猪  阅读(162)  评论(0)    收藏  举报