Understanding Isolated Storage - Day 3 - Part 6

Download this episode

Download Video

Description

Each Windows Phone 7 application is allocated space on the phone's flash drive where it can store information in a solitary area that cannot be accessed by other applications. The application can save any type of file or data here. In this video, Bob demonstrates how to utilize this feature to create new files or open existing files (like text files), read them, and display their information on the Phone's display.

Download the source code in c#

Download the source code in VB.Net

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Brendan

      Hi Bob
      Where abouts is isolated storage found on the computer during wp7 emulation? This would be convenient to know for debugging.
      Thanks,
      Brendan

    • User profile image
      Stephen Borders

      I am getting errors on the "IsolatedStorageFile" and "StreamWriter" items in the code. I have both verified the code is the same as the video and copied the Code from the MainPage.Xaml.cs source code and it still flags it as an error.

    • User profile image
      TimothyRice

      I'm also getting the same issues with IsolateStorageFile and StreamWriter :/

    • User profile image
      TimothyRice

      If you pause the video at 3:14, you can see that new code appears in lines 13 and 14.  Adding the following code to lines 13 and 14 appears to solve the issue.

      using System.IO.IsolatedStorage;
      using System.IO;

    • User profile image
      Aaron Agema

      this also brings up the (small) issue, that if someone were to get this exact example from the marketplace and click the "open" button before anything was saved, you would have the same issue as when restarting your phone emulator, i.e. the unhandled exception. make sure to use some kind of error-catching, or at least a simple if statement to check whether the file exists.

    • User profile image
      dicey

      The thing is the data stored are not overwritten when a new data is stored. hence when the new data (e.g. 12345) has less characters than the previous data (e.g. 987654321), and when we recall the data, the part of the prvious data after the new data is recalled as well (e.g. 123454321).

      So how do we completely clear out the previous data when the new data is stored?

    • User profile image
      petaganayr

      Very cool indeed.

    • User profile image
      Shawn

      Great video series!!
      My question relates to the saved file (simple.txt) and the open/recall function. When the user enters new information and saves it to the flash memory of the device, the old entry is not completely overwritten. The user has to termintate the program to completely clear the initial message from the flash memory. Is there a fix to this? If so, what is it? That would have been a great ending to this video...and helped me tremendously!

    • User profile image
      Cyrill

      @Shawn: You need to delete the file before writing with something like

      using

      (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
      {
      storage.Remove();

      }

       

    • User profile image
      minompi

      Hi, i have a question:

      if I switch off my phone after saved my file, when i restart the phone the file is deleted, clear, or is the same that i have svaed before?

      Thanks

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.