IsolatedStorageFileStream Class

Overview

  • Represents a sandbox location to store application specific data in.
  • Assembly/Machine store for application-level data.
  • Assembly/User store for user-level data.
  • File paths are relative inside a store.

Good practice

  • Don't write your state to local .xml files everywhere on the system, but store them in an IsolatedStorage.

Examples

Using a Store

IsolatedStorageFile a = IsolatedStorageFile.GetMachineStoreForAssembly();
IsolatedStorageFileStream b = new IsolatedStorageFileStream("MyState.config", FileMode.OpenOrCreate, a);
 
StreamWriter c = new StreamWriter(b);
c.WriteLine("Hello World!");
c.Close();
 
foreach (var storeFile in a.GetFileNames("*"))
{
    Console.WriteLine(storeFile);
}
 
IsolatedStorageFileStream d = new IsolatedStorageFileStream("MyState.config", FileMode.Open, a);
 
StreamReader e = new StreamReader(d);
Console.WriteLine(e.ReadToEnd());
e.Close();