Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

Retrieving Resources in .Resources Files

If your application does not deploy resources in satellite assemblies, you can access .resources files directly. Use the ResourceManager.CreateFileBasedResourceManager method to specify a directory containing loose .resources files. With this approach, it is not necessary to store all the resource files in separate subdirectories, because you will give the resource files different names based upon the cultures they represent. It is good practice, however, to place all the resources for an application in a single subdirectory of the main application directory. The following illustration shows where resource files should be located in the directory structure.

Application directory containing .resources files

After you have created your resources and placed them in the appropriate directory, create a ResourceManager to use the resources. The following example creates a ResourceManager. The first parameter specifies the resource file baseName. The second parameter specifies the location of the resources. The third parameter specifies the ResourceSet implementation to use. If the third parameter is null (C#) or Nothing (Visual Basic), the default runtime ResourceSet is used.

Dim rm As ResourceManager
rm = ResourceManager.CreateFileBasedResourceManager("strings",".",Nothing)

[C#]
ResourceManager rm =
ResourceManager.CreateFileBasedResourceManager("strings",".",null);
Note   You should not deploy ASP.NET applications using loose .resources files. This can cause locking issues and breaks XCOPY deployment. It is strongly recommended that you deploy ASP.NET resources in satellite assemblies. For more information, see Resources in ASP.NET Applications.

See Also

Resources in Applications | Packaging and Deploying Resources | ResourceManager Class | Retrieving Resources in Satellite Assemblies

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.