Answered Configuration File Setting to Textbox

tdignan87

Well-known member
Joined
Jul 8, 2019
Messages
95
Programming Experience
Beginner
Hi i am trying to move contents of the app.config file to textbox.
I have tried the following code but its not working on my form load event

The name of the config is indeed DATALOGIC_IP
C#:
 string DatalogicIP = ConfigurationManager.AppSettings["DATALOGIC_IP"];
            string DatalogicPort = ConfigurationManager.AppSettings["DATALOGIC_PORT"];
            string DBPath = ConfigurationManager.AppSettings["DB_PATH"];
            string DBPort = ConfigurationManager.AppSettings["DB_PORT"];
            string DBUserName = ConfigurationManager.AppSettings["DB_USER"];
            string DBPassword = ConfigurationManager.AppSettings["DB_PASSWORD"];


            IPAddressTxtBox.Text = DatalogicIP;
 
If you added the settings in Settings tab of project properties use the generated code for each setting, for example: Properties.Settings.Default.DATALOGIC_IP

ConfigurationManager.AppSettings is for the appSettings section in App.config, an old settings system from .Net 1, and is not the same as the project application/user settings.
 
For future reference, please set and reset the Prefix of your thread title to provide useful information, i.e. Question when asking a question and Answered when that question is answered. That way, we will know that opening the thread and reading all the posts will be a waste of time without actually doing it. I have done the latter for this thread.
 
Back
Top Bottom