Read and write with IsolatedStorageFileStream in CSharp

Description

The following code shows how to read and write with IsolatedStorageFileStream.

Example


      /*from  w w  w  .j a v a 2 s  .c  o m*/
using System;
using System.IO;
using System.IO.IsolatedStorage;
class UseIsolatedStorage 
{  
  public static void Main() 
  {
    IsolatedStorageFileStream file = new IsolatedStorageFileStream("MyApp.preferences", FileMode.Create);
    StreamWriter sw = new StreamWriter(file);
    sw.WriteLine("UserType=Analyst");
    sw.WriteLine("UserModer=Advanced");
    sw.Close();
    file.Close();

    file = new IsolatedStorageFileStream("MyApp.preferences", FileMode.Open);
    StreamReader reader = new StreamReader(file);
    String prefs = reader.ReadToEnd();
    Console.WriteLine(prefs);
    file.Close();
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    IO »




File Attribute
File Security
Directory Attribute
Directory Recursive
Binary File
Text Field
Buffered IO
Create Copy Delete Move
CSV
Drive
File System Watcher
Isolated Storage
MemoryStream
Serialize
Zip