Isolated storage allows an assembly or application domain to have a reserved space in the file system to store sensitive yet persistent data. This is not completely secure, but portions of the .NET Framework Security use isolated storage to access and manipulate items in the store in a secure manner. After you obtain an isolated storage file (a store), you can use standard I/O facilities to read and write files and directories within the store. You don't have to worry about any other application corrupting your data because each application (application domain or assembly) accesses only its area in isolated storage. Listing 16.17 shows a sample of how to use isolated storage.
The readFromFile function has been omitted because the implementation is similar to writeToFile.
To use IsolatedStorage, call one of two static functions:
GetUserStoreForAssembly— This returns an IsolatedStorageFile that is specific to the calling assembly.
GetUserStoreForDomain— This returns an IsolatedStorageFile that is specific to the calling application domain.
After you have an IsolatedStorageFile, you can use it to create an IsolatedStorageFileStream. After you have a stream, you can use any of the IO facilities that takes a stream to read and write to the store.
You can administer the isolated storage with a utility called storeadm. After you run the program associated with Listing 16.17, invoke storeadm /list to get the following output:
Record #1 [Assembly] <System.Security.Policy.Url version="1"> <Url>file://D:/IsolatedStorage.exe</Url> </System.Security.Policy.Url> Size : 1024
If you call storeadm with no arguments, you get a usage report that provides some of the options that you need to administer the store. One of the most useful options is storeadm/remove, which allows you to remove the store completely.
3.22.248.208