Take Advantage of Isolated Storage with .NET
Testing the IsoStorage Class
Below is a simple console application that gets an instance of the AppItems collection, adds several AppItem objects to the collection, and then stores the collection on disk. Finally, it reads that same collection from the disk and echoes the name/value pairs to the console. The following is the complete code for this test app:
using System;
using amundsen.Utility;
public class IsoConsole
{
public static void Main()
{
AppItems writeItems = new amundsen.Utility.AppItems();
writeItems.Add(new AppItem("name","mike"));
writeItems.Add(new AppItem("amount",13.5));
writeItems.Add(new AppItem("datepaid",System.DateTime.Now));
amundsen.Utility.IsoStorage iso = new amundsen.Utility.
IsoStorage();
iso.WriteAppCollection("testing.txt",writeItems);
AppItems readItems = iso.ReadAppCollection("testing.txt");
for(int i=0;i<readItems.Count;i++)
{
AppItem item = (AppItem)readItems[i];
Console.WriteLine(String.Format("{0}={1}",item.Name,
item.Value));
}
}
}
Below is the resulting output when you run the above code:
But where, you might ask, is this information stored on the disk? It depends on which Windows OS you are using and whether it was a fresh install or an upgrade from an older OS. However, clean installs of XP and Windows 2003 store the data in a unique folder name within <SYSTEMDRIVE>\Documents and Settings\<user>\Local Settings\Application Data. They store roaming profiles in a different location. When I ran this example on my machine, the OS stored the testing.txt file in a folder called AssemFiles at this location:
C:\Documents and Settings\MCA\Local Settings\Application Data\IsolatedStorage\i3ltsz13.04j\ybsvcgd0.iwo\Url.jw0fj4okszugu4hi3vglikpjpr4ih0nd
A Safe Place for Your Data
Now you know that .NET provides a safe location for storing application- and user-specific data. You've also learned how to access this isolated storage space and how to build a simple utility class that can easily read and write name/value pairs to it.
About the Author
Downloads
More for Developers
Top Authors
- Voted: 13 times.
- Voted: 11 times.
- Voted: 11 times.
- Voted: 8 times.
- Voted: 8 times.
- Paul Kimmel 214 articles
- Zafir Anjum 120 articles
- 15Seconds.com 99 articles
- Tom Archer - MSFT 83 articles
- Jeffrey Juday 82 articles


All