Hi Shagun,
You could try this :
string sResxPath = @"D:\Appz\App_GlobalResources\somefile.resx";
Hashtable data = new Hashtable();
data.Add("name", "George");
UpdateResourceFile(data, sResxPath);
public static void UpdateResourceFile(Hashtable data, String path)
{
Hashtable resourceEntries = new Hashtable();
ResXResourceReader reader = new ResXResourceReader(path);
if (reader != null)
{
IDictionaryEnumerator id = reader.GetEnumerator();
foreach (DictionaryEntry d in reader)
{
if (d.Value == null)
resourceEntries.Add(d.Key.ToString(), "");
else
resourceEntries.Add(d.Key.ToString(), d.Value.ToString());
} reader.Close();
}
foreach (String key in data.Keys)
{
if (!resourceEntries.ContainsKey(key))
{
String value = data[key].ToString();
if (value == null)
value = "";
resourceEntries.Add(key, value);
}
else
{
String value = data[key].ToString();
if (value == null)
value = "";
resourceEntries.Remove(key);
resourceEntries.Add(key, data[key].ToString());
}
}
ResXResourceWriter resourceWriter = new ResXResourceWriter(path);
foreach (String key in resourceEntries.Keys)
{
resourceWriter.AddResource(key, resourceEntries[key]);
}
resourceWriter.Generate();
resourceWriter.Close();
}
Hope this helps.