Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
 Retrieving Resources in .Resources ...
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Developer's Guide
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

Main directory for your application

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.

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

C#
ResourceManager rm =
ResourceManager.CreateFileBasedResourceManager("strings",".",null);
NoteNote:

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.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker