private void IsolatedStorageFileDemo() { string isolatedFileName = "DemoIsolatedFile.txt"; //文件名 IsolatedStorageFile isoStore; IsolatedStorageFileStream isoStream; StreamWriter myWrite; //写 StreamReader myReader; //读 string lineFormIsolatedFile; isoStore = IsolatedStorageFile.GetUserStoreForApplication(); //取得用户Application的地址 //打开指定的文件,以创建的方式 isoStream = new IsolatedStorageFileStream(isolatedFileName,FileMode.Create,isoStore); //写入文件 myWrite = new StreamWriter(isoStream); myWrite.WriteLine("Writing to isolated storage files is easy!"); myWrite.WriteLine("It is also secure and stable."); myWrite.Close(); //读取文件 isoStream = new IsolatedStorageFileStream(isolatedFileName,FileMode.Open, isoStore); myReader = new StreamReader(isoStream); while ((lineFormIsolatedFile = myReader.ReadLine()) != null) { //Console.WriteLine(lineFormIsolatedFile); MessageBox.Show(lineFormIsolatedFile); } myReader.Close(); }
网上学的。。。。