title: Saving and Loading Image to IsolatedStorage Requires Saving Twice
body: <p>I am using <a href="http://imagetools.codeplex.com" rel="noreferrer">ImageTools</a> from codeplex in order to save a canvas as a png; however, I had the same problem when I was using a <code>writeableBitmap.SaveJpeg()</code>. Therefore, the problem is not with the image type, but rather with how I am saving or loading in <code>IsolatedStorage</code>. </p>
  
  <p>When I save the image by pressing a save button the file exists, but when I load the image nothing appears. If I save the image twice then the image loads and is displayed correctly.</p>
  
  <p>Below is my code.</p>
  
  <p>Saving File:</p>
  
  <pre><code>ExtendedImage myImage = myCanvas.ToImage();
  
  using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
  {
      if (isoStore.FileExists("image.png"))
         isoStore.DeleteFile("image.png");
  
      using (var fileStream = isoStore.CreateFile("image.png"))
      {
          myImage.WriteToStream(fileStream, "image.png");
          fileStream.Close();
      }
  }
  </code></pre>
  
  <p>Loading file</p>
  
  <pre><code>BitmapImage bi = new BitmapImage();
  
  using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
  {
      if (isoStore.FileExists("image.png"))
      {
          using (var fileStream = isoStore.OpenFile("image.png", FileMode.Open))
          {
              bi.SetSource(fileStream);
              this.img.Height = bi.PixelHeight;
              this.img.Width = bi.PixelWidth;
              this.img.Source = bi;
          }
      }
  }
  </code></pre>