49,796 Members
0 added today
329,947 Resources
210 added today

All Devdex   All Gurus  

How to retrieve a value from Resource File using C#
Author: Mahesh ChandraMouli
Rating: Rate this Resource
Visits: 27451

Discuss in Newsgroups

This sample describes how to retrieve the values which are stored in Resource file and also explains how can you can convert a text file into an resource file.


1. The below example describes how to retrieve a value from a resource file.


Code Snippet

 using System;
 using System.Resources;

 // specify your resource file name 
 string m_sResourceFileName = "filename";

 // it returns your path where the resource file is stored
 string v_sPath = System.AppDomain.CurrentDomain.BaseDirectory.ToString();   

 // creates a resource manager  
 ResourceManager v_ResMan =

ResourceManager.CreateFileBasedResourceManager(m_sResourceFileName,v_sPath,null);
 
 // it retrieves the connection string value
 string m_connectionstring = v_ResMan.GetString("connectionstring");


2. The below shows how can we convert a text file into an resource file.

Resource File Generator (Resgen.exe)
 
The Resource File Generator converts .txt files and .resx (XML-based resource format) files to common language runtime

binary .resources files that can be embedded in a runtime binary executable or compiled into satellite assemblies. Resgen.exe

performs the following conversions:

Converts .txt files to .resources or .resx files.


In the command prompt>>>resgen filename.txt

when you execute this statement in the command prompt the textfile will be converted to resourcefile.

 

 


Visit my guru profile

Visitor Comments

Be the first to rate this code sample!

 

Rate this Code Sample






	
	
	



ASP.NET Chart Control.
Charts from your Database.
Live Demo & FREE Trial!

ASP ArticlesThis category has been added to your weekly newsletter
ASP Web Sites
ADSI & WSH BooksThis category has been added to your weekly newsletter
FREE ComponentsThis category has been added to your weekly newsletter
ASP EventsThis category has been added to your weekly newsletter
ASP HeadlinesThis category has been added to your weekly newsletter

CSharp ArticlesThis category has been added to your weekly newsletter
C# Web SitesThis category has been added to your weekly newsletter

SQL ArticlesThis category has been added to your weekly newsletter
SQL Events
SQL HeadlinesThis category has been added to your weekly newsletter
SQL Jobs

Jobs in CaliforniaThis category has been added to your weekly newsletter

XML ArticlesThis category has been added to your weekly newsletter
XML BooksThis category has been added to your weekly newsletter
XML Web Sites
XML Tutorials

free asp host

"Alex Homer"This search has been added to your weekly newsletter

Edit My Favorites Edit Profile & Favorites

 




Developersdex Home | ASP | C# | SQL | VB | XML | Gurus
Add Your Link | Add Your Code | FAQ | Advertise | Link To Us | Contact Us |
Copyright © 2010 Developersdex™. All rights reserved.