Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

IsolatedStorageFile.GetUserStoreForDomain Method

Obtains user-scoped isolated storage corresponding to the application domain identity and assembly identity.

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

public static IsolatedStorageFile GetUserStoreForDomain()

Return Value

Type: System.IO.IsolatedStorage.IsolatedStorageFile
An object corresponding to the IsolatedStorageScope, based on a combination of the application domain identity and the assembly identity.


Sufficient isolated storage permissions have not been granted.


The store failed to open.


The assembly specified has insufficient permissions to create isolated stores.


An isolated storage location cannot be initialized.


The permissions for the application domain cannot be determined.

The same assembly code will use different isolated stores when used in the context of different applications.

GetUserStoreForDomain is functionally equivalent to the following code:

isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.Assembly |
    IsolatedStorageScope.Domain | IsolatedStorageScope.User,
    null, null);

Different assemblies running within the same application domain always have distinct isolated stores.


GetUserStoreForDomain will return an IsolatedStorageFile object without a quota if the application domain in which the assembly is installed does not have IsolatedStorageFilePermission. Later attempts to create an IsolatedStorageFile object using the IsolatedStorageFile object that does not have a quota will fail with an IsolatedStorageException.

The following code example demonstrates the GetUserStoreForDomain method. For the complete context of this example, see the IsolatedStorageFile overview.

IsolatedStorageFile isoFile;
isoFile = IsolatedStorageFile.GetUserStoreForDomain();

// Open or create a writable file.
IsolatedStorageFileStream isoStream =
    new IsolatedStorageFileStream(this.userName,

StreamWriter writer = new StreamWriter(isoStream);
// 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.
return d;

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

© 2015 Microsoft