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)

來源:
IsolatedStorageFile.cs
來源:
IsolatedStorageFile.cs
來源:
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)

來源:
IsolatedStorageFile.cs
來源:
IsolatedStorageFile.cs
來源:
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

包含應用程式識別的物件。

傳回

表示參數的物件。

例外狀況

尚未授與足夠的隔離儲存區使用權限。

applicationEvidence尚未傳入身分識別。

scope 無效。

無法初始化隔離的儲存區位置。

-或-

scope 包含 列舉值 Application ,但無法判斷呼叫端的應用程式識別,因為 ActivationContext 傳回 null 之目前應用程式域的 。

-或-

scope 包含Domain 值,但無法判斷應用程式定義域的使用權限。

-或-

scope 包含Assembly 值,但無法判斷呼叫組件的使用權限。

備註

注意

scope如果 參數是 Application ,而且安裝元件的應用程式域沒有 IsolatedStorageFilePermission ,則 GetStore 方法會傳回 IsolatedStorageFile 不含配額的物件。 稍後嘗試使用 IsolatedStorageFile 沒有配額的物件來建立 IsolatedStorageFile 物件,將會失敗。 IsolatedStorageException

另請參閱

適用於

GetStore(IsolatedStorageScope, Object, Object)

來源:
IsolatedStorageFile.cs
來源:
IsolatedStorageFile.cs
來源:
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

物件,該物件包含程式碼組件識別的辨識項。

傳回

表示參數的物件。

例外狀況

尚未授與足夠的隔離儲存區使用權限。

未傳入 domainIdentityassemblyIdentity。 這會驗證所使用的是正確的建構函式。

-或-

domainIdentityassemblyIdentitynull

scope 無效。

無法初始化隔離的儲存區位置。

-或-

scope 包含 列舉值 Application ,但無法判斷呼叫端的應用程式識別,因為 ActivationContext 傳回 null 之目前應用程式域的 。

-或-

scope 包含Domain 值,但無法判斷應用程式定義域的使用權限。

-或-

scope 包含Assembly 值,但無法判斷呼叫組件的使用權限。

備註

這種形式 GetStore 最適用于需要開啟存放區的系統管理程式碼,就像是另一個元件一樣。 儲存區會針對所提供的辨識項開啟,而不是針對目前執行中的元件開啟。

注意

scope如果 參數是 Domain ,而且安裝元件的應用程式域沒有 IsolatedStorageFilePermission ,則 GetStore 方法會傳回 IsolatedStorageFile 不含配額的物件。 稍後嘗試使用 IsolatedStorageFile 沒有配額的物件來建立 IsolatedStorageFile 物件,將會失敗。 IsolatedStorageException

另請參閱

適用於

GetStore(IsolatedStorageScope, Type, Type)

來源:
IsolatedStorageFile.cs
來源:
IsolatedStorageFile.cs
來源:
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( 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

另請參閱

適用於