NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Accessing Files and Data in a Store

Having created a store, you can create and open a file so that you can store data in it. To create and open the file, you can use an IsolatedStorageFileStream constructor, passing in the file name, the FileMode.OpenOrCreate enumeration value, and the IsolatedStorageFile object you obtained when you created the store. Then, you can do the things you would typically expect to do with data in a file stream, such as read, seek, and write. You can also open the file for other purposes using the IsolatedStorageFileStream constructor. If you do not pass in a store to the IsolatedStorageFileStream constructor, the constructor will get the user-, domain-, assembly-isolated store for you.

To open a file called “options” in a store that is isolated by user, domain, and assembly and write the string "blue" to the file, you could write the following C# code:

IsolatedStorageFileStream stream;
string data = "blue";
stream = new IsolatedStorageFileStream("options", FileMode.OpenOrCreate);
StreamWriter writer = new StreamWriter(stream); 
writer.WriteLine(data);
writer.Close(); // implicitly closes stream