IsolatedStorageFile.GetStore Method

Definition

Obtains isolated storage corresponding to the given application domain and assembly evidence objects and isolated storage scope.

Overloads

GetStore(IsolatedStorageScope, Object)

Obtains isolated storage corresponding to the given application identity.

GetStore(IsolatedStorageScope, Type)

Obtains isolated storage corresponding to the isolation scope and the application identity object.

GetStore(IsolatedStorageScope, Object, Object)

Obtains the isolated storage corresponding to the given application domain and assembly evidence objects.

GetStore(IsolatedStorageScope, Type, Type)

Obtains isolated storage corresponding to the isolated storage scope given the application domain and assembly evidence types.

GetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type)

Obtains isolated storage corresponding to the given application domain and the assembly evidence objects and types.

GetStore(IsolatedStorageScope, Object)

Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs

Obtains isolated storage corresponding to the given application identity.

C#
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, object? applicationIdentity);
C#
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, object applicationIdentity);

Parameters

scope
IsolatedStorageScope

A bitwise combination of the enumeration values.

applicationIdentity
Object

An object that contains evidence for the application identity.

Returns

An object that represents the parameters.

Exceptions

Sufficient isolated storage permissions have not been granted.

The applicationIdentity identity has not been passed in.

The scope is invalid.

An isolated storage location cannot be initialized.

-or-

scope contains the enumeration value Application, but the application identity of the caller cannot be determined,because the ActivationContext for the current application domain returned null.

-or-

scope contains the value Domain, but the permissions for the application domain cannot be determined.

-or-

scope contains the value Assembly, but the permissions for the calling assembly cannot be determined.

Remarks

Note

If the scope parameter is IsolatedStorageScope.Application and the application domain in which the assembly is installed does not have IsolatedStorageFilePermission, the GetStore method will return an IsolatedStorageFile object without a quota. Later attempts to create an IsolatedStorageFile object using the IsolatedStorageFile object that does not have a quota will fail with an IsolatedStorageException.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetStore(IsolatedStorageScope, Type)

Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs

Obtains isolated storage corresponding to the isolation scope and the application identity object.

C#
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, Type? applicationEvidenceType);
C#
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, Type applicationEvidenceType);

Parameters

scope
IsolatedStorageScope

A bitwise combination of the enumeration values.

applicationEvidenceType
Type

An object that contains the application identity.

Returns

An object that represents the parameters.

Exceptions

Sufficient isolated storage permissions have not been granted.

The applicationEvidenceType identity has not been passed in.

The scope is invalid.

An isolated storage location cannot be initialized.

-or-

scope contains the enumeration value Application, but the application identity of the caller cannot be determined, because the ActivationContext for the current application domain returned null.

-or-

scope contains the value Domain, but the permissions for the application domain cannot be determined.

-or-

scope contains the value Assembly, but the permissions for the calling assembly cannot be determined.

Remarks

Note

If the scope parameter is Application and the application domain in which the assembly is installed does not have IsolatedStorageFilePermission, the GetStore method will return an IsolatedStorageFile object without a quota. Later attempts to create an IsolatedStorageFile object using the IsolatedStorageFile object that does not have a quota will fail with an IsolatedStorageException.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetStore(IsolatedStorageScope, Object, Object)

Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs

Obtains the isolated storage corresponding to the given application domain and assembly evidence objects.

C#
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, object? domainIdentity, object? assemblyIdentity);
C#
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, object domainIdentity, object assemblyIdentity);

Parameters

scope
IsolatedStorageScope

A bitwise combination of the enumeration values.

domainIdentity
Object

An object that contains evidence for the application domain identity.

assemblyIdentity
Object

An object that contains evidence for the code assembly identity.

Returns

An object that represents the parameters.

Exceptions

Sufficient isolated storage permissions have not been granted.

Neither domainIdentity nor assemblyIdentity has been passed in. This verifies that the correct constructor is being used.

-or-

Either domainIdentity or assemblyIdentity is null.

The scope is invalid.

An isolated storage location cannot be initialized.

-or-

scope contains the enumeration value Application, but the application identity of the caller cannot be determined, because the ActivationContext for the current application domain returned null.

-or-

scope contains the value Domain, but the permissions for the application domain cannot be determined.

-or-

scope contains the value Assembly, but the permissions for the calling assembly cannot be determined.

Remarks

This form of GetStore is most useful for administrative code that needs to open a store as if it were another assembly. The store is opened for the evidence provided and not for the currently executing assembly.

Note

If the scope parameter is Domain and the application domain in which the assembly is installed does not have IsolatedStorageFilePermission, the GetStore method will return an IsolatedStorageFile object without a quota. Later attempts to create an IsolatedStorageFile object using the IsolatedStorageFile object that does not have a quota will fail with an IsolatedStorageException.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetStore(IsolatedStorageScope, Type, Type)

Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs
Source:
IsolatedStorageFile.cs

Obtains isolated storage corresponding to the isolated storage scope given the application domain and assembly evidence types.

C#
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, Type? domainEvidenceType, Type? assemblyEvidenceType);
C#
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType);

Parameters

scope
IsolatedStorageScope

A bitwise combination of the enumeration values.

domainEvidenceType
Type

The type of the Evidence that you can chose from the list of Evidence present in the domain of the calling application. null lets the IsolatedStorage object choose the evidence.

assemblyEvidenceType
Type

The type of the Evidence that you can chose from the list of Evidence present in the domain of the calling application. null lets the IsolatedStorage object choose the evidence.

Returns

An object that represents the parameters.

Exceptions

Sufficient isolated storage permissions have not been granted.

The scope is invalid.

The evidence type provided is missing in the assembly evidence list.

-or-

An isolated storage location cannot be initialized.

-or-

scope contains the enumeration value Application, but the application identity of the caller cannot be determined, because the ActivationContext for the current application domain returned null.

-or-

scope contains the value Domain, but the permissions for the application domain cannot be determined.

-or-

scope contains Assembly, but the permissions for the calling assembly cannot be determined.

Examples

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

C#

// Retrieve an IsolatedStorageFile for the current Domain and Assembly.
IsolatedStorageFile isoFile =
    IsolatedStorageFile.GetStore(IsolatedStorageScope.User |
    IsolatedStorageScope.Assembly |
    IsolatedStorageScope.Domain,
    null,
    null);

IsolatedStorageFileStream isoStream =
    new IsolatedStorageFileStream("substituteUsername",
    System.IO.FileMode.Open,
    System.IO.FileAccess.Read,
     System.IO.FileShare.Read);

Remarks

This is the overload of GetStore most likely to be called from application code.

This overload of GetStore opens an isolated store for the evidence types that are passed in.

Note

If the scope parameter is Domain and the application domain in which the assembly is installed does not have IsolatedStorageFilePermission, the GetStore method will return an IsolatedStorageFile object without a quota. Later attempts to create an IsolatedStorageFile object using the IsolatedStorageFile object that does not have a quota will fail with an IsolatedStorageException.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

GetStore(IsolatedStorageScope, Evidence, Type, Evidence, Type)

Obtains isolated storage corresponding to the given application domain and the assembly evidence objects and types.

C#
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore(System.IO.IsolatedStorage.IsolatedStorageScope scope, System.Security.Policy.Evidence domainEvidence, Type domainEvidenceType, System.Security.Policy.Evidence assemblyEvidence, Type assemblyEvidenceType);

Parameters

scope
IsolatedStorageScope

A bitwise combination of the enumeration values.

domainEvidence
Evidence

An object that contains the application domain identity.

domainEvidenceType
Type

The identity type to choose from the application domain evidence.

assemblyEvidence
Evidence

An object that contains the code assembly identity.

assemblyEvidenceType
Type

The identity type to choose from the application code assembly evidence.

Returns

An object that represents the parameters.

Exceptions

Sufficient isolated storage permissions have not been granted.

The domainEvidence or assemblyEvidence identity has not been passed in.

The scope is invalid.

An isolated storage location cannot be initialized.

-or-

scope contains the enumeration value Application, but the application identity of the caller cannot be determined, because the ActivationContext for the current application domain returned null.

-or-

scope contains the value Domain, but the permissions for the application domain cannot be determined.

-or-

scope contains the value Assembly, but the permissions for the calling assembly cannot be determined.

Examples

The following code example obtains storage based on publisher evidence.

C#
using System;
using System.IO;
using System.IO.IsolatedStorage;
using System.Security;
using System.Security.Policy;
using System.Security.Permissions;
using System.Security.Cryptography.X509Certificates;

class Program
{
    static void Main(string[] args)
    {
        try
        {

            if (Test())
            {
                Console.WriteLine("PASSED.");
                Environment.ExitCode = 100;
            }
            else
            {
                Console.WriteLine("FAILED.");
                Environment.ExitCode = 101;
            }
        }
        catch (Exception e)
        {
            Console.Write("Exception occurred: {0}", e.ToString());
            Environment.ExitCode = 101;
        }
        return;
    }

    public static Boolean Test()
    {
        Boolean bRes = true;

        Evidence evidence1 = GetTestEvidence();
        Evidence evidence2 = GetTestEvidence();

        IsolatedStorageFile isf = IsolatedStorageFile.GetStore(
                                    IsolatedStorageScope.User | IsolatedStorageScope.Assembly,
                                    evidence1,
                                    typeof(System.Security.Policy.Publisher),
                                    evidence2,
                                    typeof(System.Security.Policy.Publisher));

        IsolatedStorageFileStream isfs = new IsolatedStorageFileStream("AdminEvd1.testfile", FileMode.OpenOrCreate, isf);
        isfs.WriteByte(5);
        isfs.Flush();
        isfs.Close();

        return bRes;
    }

    public static Evidence GetTestEvidence()
    {
        // For demonsration purposes, use a blank certificate.
        Publisher pub = new Publisher(new X509Certificate(new Byte[64]));
        Object[] arrObj = new Object[1];
        arrObj[0] = (Object)pub;
        return new Evidence(arrObj, arrObj);
    }
}

Remarks

Note

If the scope parameter is Domain and the application domain in which the assembly is installed does not have IsolatedStorageFilePermission, the GetStore method will return an IsolatedStorageFile object without a quota. Later attempts to create an IsolatedStorageFile object using the IsolatedStorageFile object that does not have a quota will fail with an IsolatedStorageException.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1