This question is related to Winform application deployment and configuration.
I am new to .net development and I am working on my first Winforms application. Whenever I deploy the application I need to set the value of the server to which the user will be connecting.
For this I have to go into program files and change the application configuration file manually using Notepad.
Not only have I heard that this is not a good practice, it is also a tedious exercise. Imagine going to half a dozen users and doing the same thing on each machine.
I am very confused as to what to do. The application config file that is in the same folder as the exe is the file thorugh which I can change the connection string (as I am given to understand).
Can anyone help me to solve the following questions.
-
How do I update the application configuration file after I install it without having to open it up in Notepad? My main concern is updating the connection string.
-
I have heard that using the registry is a possibility in this case. I am scared of using the registry! Is this an option?
Please excuse my ignorance if the questions are naive. I am new to .net and looking for answers
Thanks
Romi
Hi Romi here is a code snippet that can help you in read/right application configurations
for write in the
to read
my advice: if your are saving several settings that are not connection strings use the above code. just create a simple form, create a dictionary fill it and show it using a grid control.
if you only need to read/write connection strings use the following code
to read
to write
config.Save(ConfigurationSaveMode.Modified);
you can still use the registry to save those settings but I belive the code above will solve your problems.