title: .NET: IsolatedStorageException
body: <p>I'm building a Windows Phone 7 app in Silverlight. I'm having difficulty with <code>IsolatedStorage</code>.</p>
  
  <pre><code>        IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
          if (!storage.FileExists(STORIES_FILE))
          {
              storage.CreateFile(STORIES_FILE);
          }
  
          string contents;
  
          // fails here
          using (IsolatedStorageFileStream stream = storage.OpenFile(STORIES_FILE, FileMode.Open))
          {
              using (StreamReader reader = new StreamReader(stream))
              {
                  contents = reader.ReadToEnd();
              }
          }
  </code></pre>
  
  <p>The exception is:</p>
  
  <pre><code>"Operation not permitted on IsolatedStorageFileStream."
  System.Exception {System.IO.IsolatedStorage.IsolatedStorageException}
  </code></pre>
  
  <p>What could I be doing wrong here? <a href="http://msdn.microsoft.com/en-us/library/cc190070(v=VS.95).aspx" rel="noreferrer">MSDN says</a> that this exception is thrown when the isolated storage is removed or disabled. Could that have happened? I'm experiencing this problem on the emulator.</p>
  
  <p><strong>Update</strong>: This appears to only happen the first time I'm running the app on the emulator. After the app crashes, I run it on the emulator again, and this problem doesn't occur.</p>
  
  <p><strong>Update 2</strong>: Using <code>FileMode.OpenOrCreate</code> instead of <code>FileMode.Open</code> appears to have solved the problem.</p>