IsolatedStorageFile.GetStore 方法

定义

获取与给定应用程序域和程序集证据对象对应的独立存储以及独立存储范围。

重载

GetStore(IsolatedStorageScope, Object)

获取与给定应用程序标识对应的独立存储。

GetStore(IsolatedStorageScope, Type)

获取与隔离范围和应用程序标识对象对应的独立存储。

GetStore(IsolatedStorageScope, Object, Object)

获取与给定的应用程序域和程序集证据对象相对应的独立存储。

GetStore(IsolatedStorageScope, Type, Type)

已知应用程序域和程序集证据类型,获取与独立存储范围对应的独立存储。

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

获取与给定应用程序域和程序集证据对象及类型对应的独立存储。

GetStore(IsolatedStorageScope, Object)

获取与给定应用程序标识对应的独立存储。

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

参数

scope
IsolatedStorageScope

枚举值的按位组合。

applicationIdentity
Object

包含应用程序标识证据的对象。

返回

表示这些参数的对象。

例外

未授予使用独立存储的足够权限。

applicationIdentity尚未传入标识。

scope 无效。

无法初始化独立的存储位置。

- 或 -

scope包含 枚举值 Application,但无法确定调用方的应用程序标识,因为ActivationContext当前应用程序域的 返回 。null

- 或 -

scope 包含值 Domain,但不能确定应用程序域的权限。

- 或 -

scope 包含值 Assembly,但不能确定调用程序集的权限。

注解

备注

scope如果 参数为 IsolatedStorageScope.Application ,并且安装程序集的应用程序域没有 IsolatedStorageFilePermission,则 GetStore 该方法将返回一个IsolatedStorageFile没有配额的对象。 稍后尝试使用IsolatedStorageFile没有配额的对象创建IsolatedStorageFile对象会失败, 并显示 IsolatedStorageException

另请参阅

适用于

GetStore(IsolatedStorageScope, Type)

获取与隔离范围和应用程序标识对象对应的独立存储。

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

参数

scope
IsolatedStorageScope

枚举值的按位组合。

applicationEvidenceType
Type

包含应用程序标识的对象。

返回

表示这些参数的对象。

例外

未授予使用独立存储的足够权限。

applicationEvidence尚未传入标识。

scope 无效。

无法初始化独立的存储位置。

- 或 -

scope包含 枚举值 Application,但无法确定调用方的应用程序标识,因为ActivationContext当前应用程序域的 返回 。null

- 或 -

scope 包含值 Domain,但不能确定应用程序域的权限。

- 或 -

scope 包含值 Assembly,但不能确定调用程序集的权限。

注解

备注

scope如果 参数为 Application ,并且安装程序集的应用程序域没有 IsolatedStorageFilePermission,则 GetStore 该方法将返回一个IsolatedStorageFile没有配额的对象。 稍后尝试使用IsolatedStorageFile没有配额的对象创建IsolatedStorageFile对象会失败, 并显示 IsolatedStorageException

另请参阅

适用于

GetStore(IsolatedStorageScope, Object, Object)

获取与给定的应用程序域和程序集证据对象相对应的独立存储。

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

参数

scope
IsolatedStorageScope

枚举值的按位组合。

domainIdentity
Object

包含应用程序域标识的证据的对象。

assemblyIdentity
Object

包含代码程序集标识的证据的对象。

返回

表示这些参数的对象。

例外

未授予使用独立存储的足够权限。

既不传递 domainIdentity,也不传递 assemblyIdentity。 这将验证使用的是正确的构造函数。

- 或 -

domainIdentityassemblyIdentitynull

scope 无效。

无法初始化独立的存储位置。

- 或 -

scope包含 枚举值 Application,但无法确定调用方的应用程序标识,因为ActivationContext当前应用程序域的 返回 。null

- 或 -

scope 包含值 Domain,但不能确定应用程序域的权限。

- 或 -

scope 包含值 Assembly,但不能确定调用程序集的权限。

注解

对于需要像另一个程序集一样打开存储的管理代码,这种形式的 GetStore 最有用。 存储是为提供的证据打开的,而不是为当前正在执行的程序集打开的。

备注

scope如果 参数为 Domain ,并且安装程序集的应用程序域没有 IsolatedStorageFilePermission,则 GetStore 该方法将返回一个IsolatedStorageFile没有配额的对象。 稍后尝试使用IsolatedStorageFile没有配额的对象创建IsolatedStorageFile对象会失败, 并显示 IsolatedStorageException

另请参阅

适用于

GetStore(IsolatedStorageScope, Type, Type)

已知应用程序域和程序集证据类型,获取与独立存储范围对应的独立存储。

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

参数

scope
IsolatedStorageScope

枚举值的按位组合。

domainEvidenceType
Type

可从调用应用程序的域内存在的 Evidence 列表中选择的 Evidence 的类型。 如果为 null,则允许 IsolatedStorage 对象选择证据。

assemblyEvidenceType
Type

可从调用应用程序的域内存在的 Evidence 列表中选择的 Evidence 的类型。 如果为 null,则允许 IsolatedStorage 对象选择证据。

返回

表示这些参数的对象。

例外

未授予使用独立存储的足够权限。

scope 无效。

所提供的证据类型没有出现在程序集证据列表中。

- 或 -

无法初始化独立的存储位置。

- 或 -

scope包含 枚举值 Application,但无法确定调用方的应用程序标识,因为ActivationContext当前应用程序域的 返回 。null

- 或 -

scope 包含值 Domain,但不能确定应用程序域的权限。

- 或 -

scope 包含 Assembly,但不能决定调用程序集的权限。

示例

下面的代码示例演示 GetStore 了 方法。 有关此示例的完整上下文,请参阅 IsolatedStorageFile 概述。

// 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)

注解

这是最有可能从应用程序代码调用的 GetStore 重载。

此 重载为 GetStore 传入的证据类型打开一个独立存储。

备注

scope如果 参数为 Domain ,并且安装程序集的应用程序域没有 IsolatedStorageFilePermission,则 GetStore 该方法将返回一个IsolatedStorageFile没有配额的对象。 稍后尝试使用IsolatedStorageFile没有配额的 对象创建 IsolatedStorageFile 对象将失败,并显示 IsolatedStorageException

另请参阅

适用于

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

获取与给定应用程序域和程序集证据对象及类型对应的独立存储。

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

参数

scope
IsolatedStorageScope

枚举值的按位组合。

domainEvidence
Evidence

包含应用程序域标识的对象。

domainEvidenceType
Type

要从应用程序域证据中选择的标识类型。

assemblyEvidence
Evidence

包含代码程序集标识的对象。

assemblyEvidenceType
Type

要从应用程序代码程序集证据中选择的标识类型。

返回

表示这些参数的对象。

例外

未授予使用独立存储的足够权限。

尚未传入 domainEvidenceassemblyEvidence 标识。

scope 无效。

无法初始化独立的存储位置。

- 或 -

scope 包含 枚举值 Application,但无法确定调用方的应用程序标识,因为 ActivationContext 当前应用程序域的 返回了 null

- 或 -

scope 包含值 Domain,但不能确定应用程序域的权限。

- 或 -

scope 包含值 Assembly,但不能确定调用程序集的权限。

示例

下面的代码示例基于发布者证据获取存储。

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

注解

备注

scope如果 参数为 Domain ,并且安装程序集的应用程序域没有 IsolatedStorageFilePermission,则 GetStore 该方法将返回一个IsolatedStorageFile没有配额的对象。 稍后尝试使用IsolatedStorageFile没有配额的 对象创建 IsolatedStorageFile 对象将失败,并显示 IsolatedStorageException

另请参阅

适用于