IsolatedStorageFileStream Class
Part of my 2008 study notes for exam 70-536 (.NET Framework 2.0).
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();
You May Also Like
ArrayList Class
Resizeable, unordered, index-based collection. Suffers from boxing/unboxing when working with value types. Implements IEnumerator, allowing foreach…
BinaryReader Class and BinaryWriter Class
Used to read and write binary data from streams. Call the correct Read methods when using a BinaryReader.
BitArray Class
Contains an array of true/false values. Resizable through the Length property. Supports bitwise operations.



