Using app.config
-
I've seen this mentioned before, and I know how to create the app.config file in my project, and I know theoretically how to read from it, but it never works for me. So, I was wondering if someone could give me a simple example of, say, the following: Create an application (using Visual Basic.Net Home Edition) that will remember the form's Opacity, Backcolor, size and position using a configuration file (app.config). I figure if I see the code for that, I'll be able to figure out how to use the app.config file to remember other stuff too. I know it can't be that hard, because lots of people seem to use it all of the time. Thanks for the help. As I sit here, I contemplate the last words of Socrates: "I drank what?".
-
I've seen this mentioned before, and I know how to create the app.config file in my project, and I know theoretically how to read from it, but it never works for me. So, I was wondering if someone could give me a simple example of, say, the following: Create an application (using Visual Basic.Net Home Edition) that will remember the form's Opacity, Backcolor, size and position using a configuration file (app.config). I figure if I see the code for that, I'll be able to figure out how to use the app.config file to remember other stuff too. I know it can't be that hard, because lots of people seem to use it all of the time. Thanks for the help. As I sit here, I contemplate the last words of Socrates: "I drank what?".
As you probably know, the app.config file is read by the framework and accessed through the ConfigurationSettings.AppSettings[^] collection. However this is a one-way communication, Reading only. The app.config AFAIK is only designed for external settings to be created for an application, and not for the application to write to.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar Coming soon: The Second EuroCPian Event[^].
-
As you probably know, the app.config file is read by the framework and accessed through the ConfigurationSettings.AppSettings[^] collection. However this is a one-way communication, Reading only. The app.config AFAIK is only designed for external settings to be created for an application, and not for the application to write to.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar Coming soon: The Second EuroCPian Event[^].
Herm... that's not good. So, should I just stick with my original idea and write a text file? That's gonna be a pain... anyway, thanks for the help. As I sit here, I contemplate the last words of Socrates: "I drank what?".
-
Herm... that's not good. So, should I just stick with my original idea and write a text file? That's gonna be a pain... anyway, thanks for the help. As I sit here, I contemplate the last words of Socrates: "I drank what?".
Settings are very easy to save in .NET, because you can serialize objects. This makes it almost trivial to create a class to represent your settings, and then use serialization to save and load it to/from disk. See
Serialization, Basic Serialization
in the .NET SDK docs. There are other ways, but that is my favourite. -
Settings are very easy to save in .NET, because you can serialize objects. This makes it almost trivial to create a class to represent your settings, and then use serialization to save and load it to/from disk. See
Serialization, Basic Serialization
in the .NET SDK docs. There are other ways, but that is my favourite.app.config is a read only mechanism. I have written a simple custom class to save/retrieve application data using hashtable and isolated storage. See if this helps : http://www.dotnetspider.com/Technology/KBPages/344.aspx :zzz:----------------------------------------------------------------------:(( T Manjaly C# Tutorials and samples : http://www.dotnetspider.com
-
I've seen this mentioned before, and I know how to create the app.config file in my project, and I know theoretically how to read from it, but it never works for me. So, I was wondering if someone could give me a simple example of, say, the following: Create an application (using Visual Basic.Net Home Edition) that will remember the form's Opacity, Backcolor, size and position using a configuration file (app.config). I figure if I see the code for that, I'll be able to figure out how to use the app.config file to remember other stuff too. I know it can't be that hard, because lots of people seem to use it all of the time. Thanks for the help. As I sit here, I contemplate the last words of Socrates: "I drank what?".