IsolatedStorageFile.Dispose Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Releases all resources used by the IsolatedStorageFile.

Namespace: System.IO.IsolatedStorage
Assembly: mscorlib (in mscorlib.dll)

Syntax

Public Sub Dispose
public void Dispose()

Implements

IDisposable..::.Dispose()()()

Remarks

As a rule, when you use an IDisposable object such as IsolatedStorageFile, you should declare and instantiate it in a using statement. The using statement calls the Dispose method on the object in the correct way, and it also causes the object itself to go out of scope as soon as Dispose is called. Within the using block, the object is read-only and cannot be modified or reassigned. For an example, see the example provided for IsolatedStorageFile class

If you don't use a using statement, always 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.

Note

Always call Dispose before you release your last reference to the IsolatedStorageFile. Otherwise, the resources the IsolatedStorageFileStream is using will not be freed until garbage collection calls the IsolatedStorageFileStream object's Finalize method.

Version Information

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Platforms

Windows Phone

See Also

Reference

IsolatedStorageFile Class

System.IO.IsolatedStorage Namespace