Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IsolatedStorageFile::GetMachineStoreForDomain Method ()

 

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

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

public:
static IsolatedStorageFile^ GetMachineStoreForDomain()

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.

Exception Condition
SecurityException

Sufficient isolated storage permissions have not been granted.

IsolatedStorageException

The store failed to open.

-or-

The assembly specified has insufficient permissions to create isolated stores.

-or-

The permissions for the application domain cannot be determined.

-or-

An isolated storage location cannot be initialized.

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

GetMachineStoreForDomain is functionally equivalent to the following code:

isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Assembly |
    IsolatedStorageScope::Domain | IsolatedStorageScope::Machine,
    (Type^)nullptr, (Type^)nullptr);

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

System_CAPS_noteNote

GetUserStoreForDomain will return an IsolatedStorageFile object without a quota if the application domain into 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 = gcnew IsolatedStorageFileStream( this->userName,FileMode::OpenOrCreate,FileAccess::Write,isoFile );
StreamWriter^ writer = gcnew 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 = {0}", isoFile->CurrentSize.ToString() );
Console::WriteLine( "MaximumSize = {0}", isoFile->MaximumSize.ToString() );
writer->Close();
isoFile->Close();
isoStream->Close();
return d;

IsolatedStorageFilePermission

for using isolated storage. Associated enumeration: DomainIsolationByUser

ReflectionPermission

when invoked late-bound through mechanisms such as Type::InvokeMember. Associated enumeration: ReflectionPermissionFlag::MemberAccess

.NET Framework
Available since 2.0
Return to top
Show:
© 2017 Microsoft