What is .Resx file in Dot Net??
It is an XML based file, with key value pair.
Reading from .Resx File:
You can access the .Resx file using this code:
ResXResourceReader reader = new ResXResourceReader(Server.MapPath("test.resx"));
IDictionaryEnumerator rsxr = reader.GetEnumerator();
foreach (DictionaryEntry d in reader)
{
Console.WriteLine(d.Key.ToString() + ":\t" + d.Value.ToString());
}
//Close the reader.
reader.Close();
Writing to .Resx File:
We can write the binary data of an image to the .Resx file using the following code
Image img = Image.FromFile("urdu.jpg");
ResXResourceWriter rsxw = new ResXResourceWriter("urdu.resx");
rsxw.AddResource("urdu.jpg",img);
rsxw.Close();
Use of .Resx File:
It is very useful while working on Localized project [Multiple Languages], You can make different resource files for different languages and depending upon the user choice you can change the Language of the application.
No comments:
Post a Comment