ResourceManager.CreateFileBasedResourceManager(String, String, Type) 方法

定义

返回一个 ResourceManager 对象,它在特定的目录中而不在资源的程序集清单。Returns a ResourceManager object that searches a specific directory instead of an assembly manifest for resources.

public:
 static System::Resources::ResourceManager ^ CreateFileBasedResourceManager(System::String ^ baseName, System::String ^ resourceDir, Type ^ usingResourceSet);
public static System.Resources.ResourceManager CreateFileBasedResourceManager (string baseName, string resourceDir, Type usingResourceSet);
static member CreateFileBasedResourceManager : string * string * Type -> System.Resources.ResourceManager
Public Shared Function CreateFileBasedResourceManager (baseName As String, resourceDir As String, usingResourceSet As Type) As ResourceManager

参数

baseName
String

资源的根名称。The root name of the resources. 例如,名为“MyResource.en-US.resources”的资源文件的根名称为“MyResource”。For example, the root name for the resource file named "MyResource.en-US.resources" is "MyResource".

resourceDir
String

要在其中搜索资源的目录的名称。The name of the directory to search for the resources. resourceDir 可以是绝对路径或应用程序目录中的相对路径。resourceDir can be an absolute path or a relative path from the application directory.

usingResourceSet
Type

要使用的自定义 ResourceSet 的类型。The type of the custom ResourceSet to use. 如果为 null,则使用默认的运行时 ResourceSet 对象。If null, the default runtime ResourceSet object is used.

返回

搜索指定目录而不是资源的程序集清单的资源管理器的新实例。A new instance of a resource manager that searches the specified directory instead of an assembly manifest for resources.

异常

baseNameresourceDir 参数为 nullThe baseName or resourceDir parameter is null.

注解

此方法返回一个资源管理器,该管理器从未嵌入到程序集的 .resources 文件中检索资源。This method returns a resource manager that retrieves resources from a .resources file that is not embedded in an assembly. 您可以使用此ResourceManager对象加载 ASP.NET 页的资源或ResourceSet测试实现。You can use this ResourceManager object to load resources for an ASP.NET page or to test a ResourceSet implementation. 有关从独立 .resources 文件检索资源的示例,请参阅检索资源一文。For an example that retrieves resources from a standalone .resources file, see the Retrieving Resources article.

此方法允许您指定ResourceSet实现。This method lets you specify a ResourceSet implementation. 如果ResourceSet不需要特定的实现,但想要使用自定义资源文件格式,应ResourceSet从类派生,重写GetDefaultReaderGetDefaultWriter方法,并将该类型传递给此构造函数。If you do not want a specific ResourceSet implementation, but would like to use a custom resource file format, you should derive from the ResourceSet class, override the GetDefaultReader and GetDefaultWriter methods, and pass that type to this constructor.

注意

使用 ASP.NET 应用程序中的独立 .resources 文件将中断 XCOPY 部署,因为在ReleaseAllResources方法显式释放资源之前,这些资源将一直保持锁定状态。Using standalone .resources files in an ASP.NET app will break XCOPY deployment, because the resources remain locked until they are explicitly released by the ReleaseAllResources method. 如果要将资源与 ASP.NET 应用程序一起部署,请将 .resources 文件编译为附属程序集。If you want to deploy resources with your ASP.NET apps, compile your .resources files into satellite assemblies.

安全性

ReflectionPermission
当通过诸如InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])等机制后期绑定调用时。when invoked late-bound through mechanisms such as InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[]). 关联枚举:MemberAccessAssociated enumeration: MemberAccess.

适用于