Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,085 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,548 people online right now. Registration is fast and FREE... Join Now!




how to read value of resource file(Default.aspx.en-US.resx)

 
Reply to this topicStart new topic

how to read value of resource file(Default.aspx.en-US.resx)

birendrakumar25
23 Apr, 2008 - 11:04 PM
Post #1

New D.I.C Head
*

Joined: 23 Apr, 2008
Posts: 1

i gor this method from this site but i am unable to access value of resx file.
public class myclass
{

//Namespace reference



#region ReadResourceFile
/// <summary>
/// method for reading a value from a resource file
/// (.resx file)
/// </summary>
/// <param name="file">file to read from</param>
/// <param name="key">key to get the value for</param>
/// <returns>a string value</returns>
public string ReadResourceValue(string file, string key)
{
//value for our return value
string resourceValue = string.Empty;
try
{
// specify your resource file name
string resourceFile = file;
// get the path of your file
string filePath = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
// create a resource manager for reading from
//the resx file
ResourceManager resourceManager = ResourceManager.CreateFileBasedResourceManager(resourceFile, filePath+"\\App_LocalResources", null);
// retrieve the value of the specified key
resourceValue = resourceManager.GetString(key);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
resourceValue = string.Empty;
}
return resourceValue;
}
#endregion
}

i am calling this method like taht
myclass s = new myclass();
string a = s.ReadResourceValue("Default.aspx.en-US.resx", "Label1Resource1.Text");


so tell me where i am mistaking and give me solution for this problem

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:05PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month