Share via


依據使用者和組件的隔離

當使用資料存放區的組件必須可以從任何應用程式的定義域存取時,依據使用者和組件的隔離是適當的。基本上,在這個情形中,隔離儲存區被用來儲存資料,且可套用至多個應用程式而且不受任何特定應用程式的限制,例如使用者的名稱或授權資訊。若要存取使用者和組件所隔離的儲存區,程式碼必須受信任以在應用程式間傳輸資訊。基本上,依據使用者和組件的隔離在內部網路上被允許,但在網際網路上則否。呼叫 IsolatedStorageFile 的靜態 GetStore 方法並傳入使用者和組件 IsolatedStorageScope 會傳回儲存區,並具有這種隔離性 (Isolation)。

下列程式碼範例擷取使用者和組件所隔離的存放區。存放區可以透過 isoFile 物件來存取。

Dim isoStore As IsolatedStorageFile
isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User Or IsolatedStorageScope.Assembly, Nothing, Nothing)
IsolatedStorageFile isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);

如需使用辨識項 (Evidence) 參數的範例,請參閱 System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(System.IO.IsolatedStorage.IsolatedStorageScope,System.Security.Policy.Evidence,System.Type,System.Security.Policy.Evidence,System.Type)

GetUserStoreForAssembly 方法可當做捷徑使用,如下列程式碼範例所示。這個捷徑不能用來開啟能夠漫遊的存放區;在此類情況中請使用 GetStore

Dim isoStore As IsolatedStorageFile
isoStore = IsolatedStorageFile.GetUserStoreForAssembly()
IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForAssembly();

請參閱

參考

GetUserStoreForAssembly

概念

隔離的類型
依據使用者、定義域和組件的隔離

其他資源

執行隔離儲存區工作