Question:
How can I make a simple settings file in VB.NET (Without using My.Settings)?
CyberXZT
2010-12-28 10:12:25 UTC
Hello! I am trying to make a program in Visual Basic .NET (Visual Studio 2008 Pro, .NET Framework 2.0) and would like to implement the ability to have the user create or load very simple settings files. The settings files should also be able to be read and written to inside the program. Can anyone provide an example on how I would do this? I do not want to use My.Settings as you can only have one My.Settings file per user and cant select its location. Additionally, it would be nice if the settings file is as simple as possible, for example:

Setting1 = blah
Testing1 = tester
Example = bleh

If anyone could show me an example of doing this or at least point me in the general direction I will be happy. Thanks.

Other notes, I have looked into using an INI file however the methods I have seen require accessing kernel.dll. I am planning on deploying this application on Linux using Mono so outside references such as that are not possible.
Four answers:
Pfo
2010-12-28 10:36:54 UTC
My.Settings is just a VB shortcut for Settings.Default. You can have multiple settings files per application, but you'll have to load and save them manually.



Check out the Settings API on MSDN.
?
2010-12-28 18:42:57 UTC
Just write the file. Load it and parse it when you start the program. Allow the user to select a setup, which you load, parse and apply. Allow the user to save a setup. You can use a select-case code block to parse the text parameters.
Gardner
2010-12-28 18:42:30 UTC
Use an XML file to store the information.

















You can then use the XMLDocument class to read & write to the file as needed.
Lapband Man
2010-12-28 22:12:09 UTC
It is actually easier to the the "My Settings". Just set the user type is "User" instead of Applications. and it work exactly like you expect.



This is the easiest way possible.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...