语言

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)

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

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

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)

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

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

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

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

返回

一个表示参数的对象。

例外

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

applicationEvidenceType标识尚未传入。

无效 scope 。

无法初始化隔离的存储位置。

-或-

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

-或-

scope 包含该值 Domain,但无法确定应用程序域的权限。

-或-

scope 包含该值 Assembly,但无法确定调用程序集的权限。

注解

注释

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

另请参阅

适用于

GetStore(IsolatedStorageScope, Object, Object)

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

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

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 通过。 这将验证正在使用正确的构造函数。

-或-

要么domainIdentityassemblyIdentity为 null.

无效 scope 。

无法初始化隔离的存储位置。

-或-

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

-或-

scope 包含该值 Domain,但无法确定应用程序域的权限。

-或-

scope 包含该值 Assembly,但无法确定调用程序集的权限。

注解

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

注释

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

另请参阅

适用于

GetStore(IsolatedStorageScope, Type, Type)

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

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

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

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

返回

一个表示参数的对象。

例外

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

domainEvidence或assemblyEvidence标识尚未传入。

无效 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

另请参阅

适用于