IsolatedStorageFile.Dispose Method ()
Releases all resources used by the IsolatedStorageFile.
Assembly: mscorlib (in mscorlib.dll)
Call Dispose when you are finished using the IsolatedStorageFile. The Dispose method leaves the IsolatedStorageFile in an unusable state. After calling Dispose, you must release all references to the IsolatedStorageFile so the garbage collector can reclaim the memory that IsolatedStorageFile was occupying.
The following code example opens an isolated storage file, uses it to write information to a stream, closes the file, and then uses themethod to release all resources.
IsolatedStorageFile isoFile; isoFile = IsolatedStorageFile.GetUserStoreForDomain(); // Open or create a writable file. IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream(this.userName, FileMode.OpenOrCreate, FileAccess.Write, isoFile); StreamWriter writer = new StreamWriter(isoStream); writer.WriteLine(this.NewsUrl); writer.WriteLine(this.SportsUrl); // Calculate the amount of space used to record the user's preferences. double d = isoFile.CurrentSize / isoFile.MaximumSize; Console.WriteLine("CurrentSize = " + isoFile.CurrentSize.ToString()); Console.WriteLine("MaximumSize = " + isoFile.MaximumSize.ToString()); // StreamWriter.Close implicitly closes isoStream. writer.Close(); isoFile.Dispose(); isoFile.Close(); return d;
Available since 10
Available since 1.1
Available since 2.0
Windows Phone Silverlight
Available since 7.0