語言

IsolatedStorageFile.GetStore 方法

定義

取得對應特定應用領域與組合證據物件的隔離儲存,以及隔離儲存範圍。

多載

名稱 Description
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
來源:
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,但無法確定呼叫組件的權限。

備註

Note

若 scope 參數為 , IsolatedStorageScope.Application 且安裝組件的應用域不具備 IsolatedStorageFilePermission,該 GetStore 方法將回傳 IsolatedStorageFile 一個沒有配額的物件。 之後嘗試使用IsolatedStorageFile該物件建立IsolatedStorageFile沒有配額的物件,將因 而IsolatedStorageException失敗。

另請參閱

適用於

GetStore(IsolatedStorageScope, Type)

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

一個包含應用程式身份的物件。

傳回

一個代表參數的物件。

例外狀況

尚未獲得足夠的隔離儲存許可。

applicationEvidenceType身份尚未傳入。

這個 scope 是無效的。

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

-或-

scope包含列舉值Application,但無法確定呼叫者的應用程式身份,因為當前應用域ActivationContext的 返回 null 。

-或-

scope 包含 Domain值 ,但無法確定應用程式域的權限。

-或-

scope 包含值 Assembly,但無法確定呼叫組件的權限。

備註

Note

若 scope 參數為 , Application 且安裝組件的應用域不具備 IsolatedStorageFilePermission,該 GetStore 方法將回傳 IsolatedStorageFile 一個沒有配額的物件。 之後嘗試使用IsolatedStorageFile該物件建立IsolatedStorageFile沒有配額的物件,將因 而IsolatedStorageException失敗。

另請參閱

適用於

GetStore(IsolatedStorageScope, Object, Object)

來源:
IsolatedStorageFile.cs
來源:
IsolatedStorageFile.cs
來源:
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沒有通過。 這可驗證所使用的建構子是正確的。

-或-

或或 domainIdentityassemblyIdentity 就是 null。

這個 scope 是無效的。

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

-或-

scope包含列舉值Application,但無法確定呼叫者的應用程式身份,因為當前應用域ActivationContext的 返回 null 。

-或-

scope 包含 Domain值 ,但無法確定應用程式域的權限。

-或-

scope 包含值 Assembly,但無法確定呼叫組件的權限。

備註

這種形式的 最 GetStore 適合需要像開啟另一個組合語言(assembly)一樣開啟儲存庫的管理程式碼。 該商店是為了提供證據而開放,而非為當前執行的議會。

Note

若 scope 參數為 , Domain 且安裝組件的應用域不具備 IsolatedStorageFilePermission,該 GetStore 方法將回傳 IsolatedStorageFile 一個沒有配額的物件。 之後嘗試使用IsolatedStorageFile該物件建立IsolatedStorageFile沒有配額的物件,將因 而IsolatedStorageException失敗。

另請參閱

適用於

GetStore(IsolatedStorageScope, Type, Type)

來源:
IsolatedStorageFile.cs
來源:
IsolatedStorageFile.cs
來源:
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(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 會為傳遞的證據類型開啟一個隔離的儲存庫。

Note

若 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

備註

Note

若 scope 參數為 , Domain 且安裝組件的應用域不具備 IsolatedStorageFilePermission,該 GetStore 方法將回傳 IsolatedStorageFile 一個沒有配額的物件。 之後嘗試使用IsolatedStorageFile該物件建立IsolatedStorageFile沒有配額的物件,將因 而IsolatedStorageException失敗。

另請參閱

適用於