Redigera

Dela via


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.

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetStore(System::IO::IsolatedStorage::IsolatedStorageScope scope, System::Object ^ applicationIdentity);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, object? applicationIdentity);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, object applicationIdentity);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * obj -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, applicationIdentity As Object) As IsolatedStorageFile

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

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.

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetStore(System::IO::IsolatedStorage::IsolatedStorageScope scope, Type ^ applicationEvidenceType);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, Type? applicationEvidenceType);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, Type applicationEvidenceType);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * Type -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, applicationEvidenceType As Type) As IsolatedStorageFile

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 applicationEvidence 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

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.

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetStore(System::IO::IsolatedStorage::IsolatedStorageScope scope, System::Object ^ domainIdentity, System::Object ^ assemblyIdentity);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, object? domainIdentity, object? assemblyIdentity);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, object domainIdentity, object assemblyIdentity);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * obj * obj -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, domainIdentity As Object, assemblyIdentity As Object) As IsolatedStorageFile

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

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.

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetStore(System::IO::IsolatedStorage::IsolatedStorageScope scope, Type ^ domainEvidenceType, Type ^ assemblyEvidenceType);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, Type? domainEvidenceType, Type? assemblyEvidenceType);
public static System.IO.IsolatedStorage.IsolatedStorageFile GetStore (System.IO.IsolatedStorage.IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * Type * Type -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, domainEvidenceType As Type, assemblyEvidenceType As Type) As IsolatedStorageFile

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.

// Retrieve an IsolatedStorageFile for the current Domain and Assembly.
IsolatedStorageFile^ isoFile = IsolatedStorageFile::GetStore( static_cast<IsolatedStorageScope>(IsolatedStorageScope::User | IsolatedStorageScope::Assembly | IsolatedStorageScope::Domain), (Type^)nullptr, nullptr );
IsolatedStorageFileStream^ isoStream = gcnew IsolatedStorageFileStream( this->userName,FileMode::Open,FileAccess::ReadWrite,isoFile );

// 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);
' Retrieve an IsolatedStorageFile for the current Domain and Assembly.
Dim isoFile As IsolatedStorageFile = _
    IsolatedStorageFile.GetStore(IsolatedStorageScope.User _
    Or IsolatedStorageScope.Assembly _
    Or IsolatedStorageScope.Domain, Nothing, Nothing)

Dim isoStream As 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

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

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

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);
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);
static member GetStore : System.IO.IsolatedStorage.IsolatedStorageScope * System.Security.Policy.Evidence * Type * System.Security.Policy.Evidence * Type -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetStore (scope As IsolatedStorageScope, domainEvidence As Evidence, domainEvidenceType As Type, assemblyEvidence As Evidence, assemblyEvidenceType As Type) As IsolatedStorageFile

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.

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);
    }
}
Imports System.IO
Imports System.IO.IsolatedStorage
Imports System.Security
Imports System.Security.Policy
Imports System.Security.Permissions
Imports System.Security.Cryptography.X509Certificates

Class Program

    Public Shared Sub Main(ByVal args() As String)
        Try
            If Test Then
                Console.WriteLine("PASSED.")
                Environment.ExitCode = 100
            Else
                Console.WriteLine("FAILED.")
                Environment.ExitCode = 101
            End If
        Catch e As Exception
            Console.Write("Exception occurred: {0}", e.ToString)
            Environment.ExitCode = 101
        End Try
        Return
    End Sub

    Public Shared Function Test() As Boolean
        Dim bRes As Boolean = True
        Dim evidence1 As Evidence = GetTestEvidence
        Dim evidence2 As Evidence = GetTestEvidence
        Dim isf As IsolatedStorageFile = IsolatedStorageFile.GetStore((IsolatedStorageScope.User _
         Or IsolatedStorageScope.Assembly), _
         evidence1, _
         GetType(System.Security.Policy.Publisher), _
         evidence2, _
         GetType(System.Security.Policy.Publisher))
        Dim isfs As IsolatedStorageFileStream = New IsolatedStorageFileStream("AdminEvd1.testfile", _
         FileMode.OpenOrCreate, isf)
        isfs.WriteByte(5)
        isfs.Flush()
        isfs.Close()
        Return bRes
    End Function

    Public Shared Function GetTestEvidence() As Evidence

        ' For demonsration purposes, use a blank certificate.
        Dim CertTemp(63) As Byte
        Dim pub As Publisher = New Publisher(New X509Certificate(CertTemp))
        Dim arrObj(0) As Object
        arrObj(0) = CType(pub, Object)
        Return New Evidence(arrObj, arrObj)
    End Function
End Class

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