Windows Phone 7 has been identified on the current version of no file system (that is, FileStream, OpenFileDialog, such as features are not available) and the database system, which need to save some user configuration information or temporary data in the development of local how to do? The answer is instead of using Silverlight's feature isolate storage to save text files, XML files, or INI files.
In fact, the biggest benefit of using isolate storage is security, because only this program can access the zone, and other programs are inaccessible. This allows you to save a sensitive data without encrypting it yourself. But this area is limited (by default 2GB), it is not able to save large data and save data for a long time. If you have to keep a large amount of data and save it for a long time, you can only save it in the cloud instead of the local.
The use of isolate storage is actually very simple, and FileStream is basically the same. The following are some basic operations code:
1. Open Isolate Storage:
Firstly, the namespace System.IO.IsolatedStorage is introduced.
Open storage IsolatedStorageFile ISF = Isolatedstoragefile.getuserstoreforapplication ();
2. To create a folder:
Isf. CreateDirectory ("MyFolder");
3. To create a file:
StreamWriter writer = new StreamWriter(new IsolatedStorageFileStream("MyFolder\\myFile.txt", FileMode.OpenOrCreate, isf));
writer.WriteLine(“Hello World!”);
writer.Close();
4. Read file:
StreamReader reader = new StreamReader(new IsolatedStorageFileStream("MyFolder\\myFile.txt", FileMode.Open, isf));
string text = reader.ReadLine();
5. To delete a file:
Isf. DeleteFile ("Myfolder\\myfile.txt");
6. To delete a folder:
Isf. DeleteDirectory ("MyFolder");
7. To determine whether a file or folder exists:
Isf. FileExit ("Myfolder\\myfile.txt");
Isf. Directoryexit ("MyFolder");
8. You can also use Isolatestoragefilestream to manipulate files or folders, which are basically the same as FileStream.
The relevant API details can be viewed
Http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage (vs.95). aspx