IsolatedStorageFile.GetUserStoreForApplication 方法

定义

获取与调用代码的应用程序标识对应的用户范围的独立存储。

public:
 static System::IO::IsolatedStorage::IsolatedStorageFile ^ GetUserStoreForApplication();
public static System.IO.IsolatedStorage.IsolatedStorageFile GetUserStoreForApplication ();
static member GetUserStoreForApplication : unit -> System.IO.IsolatedStorage.IsolatedStorageFile
Public Shared Function GetUserStoreForApplication () As IsolatedStorageFile

返回

与基于调用代码的程序集标识的独立存储范围对应的对象。

例外

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

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

- 或 -

未能确定调用方的应用程序标识,因为 ActivationContext 属性返回了 null

- 或 -

不能确定应用程序域的权限。

注解

使用此方法时,与应用程序关联的所有程序集都使用相同的独立存储。 仅当可以确定应用程序标识时(例如,通过 ClickOnce 部署发布应用程序或基于 Silverlight 的应用程序)时,才能使用此方法。 如果尝试在基于 ClickOnce 或 Silverlight 的应用程序之外使用此方法,将收到异常 IsolatedStorageException ,因为无法确定调用方的应用程序标识。

GetUserStoreForApplication 在功能上等效于以下代码:

isoFile = IsolatedStorageFile::GetStore(IsolatedStorageScope::Application |
    IsolatedStorageScope::User, (Type^)nullptr);
isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.Application |
    IsolatedStorageScope.User, null);
isoFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.Application Or _
    IsolatedStorageScope.User, Nothing)

在此代码中 applicationIdentity , 的 GetStore(IsolatedStorageScope scope, Object applicationIdentity) 参数为 null

适用于

另请参阅