Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
1.67/5 (5 votes)
Hello
How to edit the string value in the resource file?
Is it possible?
And How to add a new value in the resource file?
pls help me !
Posted
Updated 15-Apr-20 2:52am
v2
Comments
Afzaal Ahmad Zeeshan 25-May-15 16:15pm    
Not a good question. This is not a question, it is more like a request for a new article on the topic, Working with Resource files in C#. That is no ones interest here. Why don't you try MSDN? Or search for this topic on Google, or CodeProject itself?
nabeghe 25-May-15 16:53pm    
i search but not found usefull result for that :(
Maciej Los 25-May-15 17:29pm    

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-May-15 17:58pm    
5ed.
—SA
Maciej Los 25-May-15 17:59pm    
Thank you, Sergey.
nabeghe 26-May-15 12:16pm    
Thanks you :) usefull
Maciej Los 26-May-15 13:31pm    
You're very welcome ;)
You cannot edit a resource string. If you want to store some string that you can alter programatically you should use a configuration file, or, even better user or app settings (that are actually a wrapper around the configuration file).

The reason that you can't change a resource string at runtime, is because the resource is compiled into your executable. If you reverse engineer the compiled *.exe or *.dll file, you can actually see your string in the code. Editing an already compiled executable file is never a good idea (unless you're trying to hack it), but when you try to do it from the executables code, it just plain impossible, as the file is locked during execution.

You can read more about user settings on MSDN. You should check out the link, as it contains detailed instructions with screenshots as to how to set your settings through GUI.

In brief, you right click your project->Properties->Settings. Now, you'll see a table where you can add, edit and remove user settings. Once you create a user setting you can use it like this:

//Read
String settingValue = Settings.Default.TestSetting;
//Write
Settings.Default.TestSetting = "newVal";
//Write settings to disk
Settings.Default.Save();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900