Configation File

MC² = ?

Member
Joined
Oct 11, 2004
Messages
7
Programming Experience
1-3
Hi

I need Some Help. I have Made a Option Form For my Project i am Making. When the User Choose his options and wants to Close the program. How can i Keep The User Seleted Options for next time He/She Opens it? Could Someone please help with this.

Cheers:)
 
VB.NET:
#Region " Read/Save "
    Public Sub ReadSave(ByVal ReadSave As String)
        If ReadSave = "Read" Then
            Dim SystemSettings As New StreamReader(Application.StartupPath & "\Settings.ini")
                StringValue = SystemSettings.ReadLine()
                BooleanValue = Convert.ToBoolean(SystemSettings.ReadLine())
                IntegerValue = Convert.ToInt32(SystemSettings.ReadLine()) 'Int32 = Integer, int16= Short, int64 = Long
                SystemSettings.Close()
        End If
        If ReadSave = "Save" Then
            Dim SystemSettings As New StreamWriter(Application.StartupPath & "\Settings.ini")
             With SystemSettings
                SystemSettings.WriteLine(StringValue)
                SystemSettings.WriteLine(CStr(BooleanValue))
                SystemSettings.WriteLine(CStr(IntegerValue))
             End With
            SystemSettings.Close()
        End If
    End Sub
#End Region

simply save the stuff needed on program exit, and on program start jes read the value(s) in and there ya go, this is an example sub you'll deffinantly need to modify it for your program(s)
 
Last edited:
The INI approach JuggaloBrotha has shown is perfectly viable, however the new standard is XML. VB8 (framework version 2) has built-in classes that utilize XML to persist settings.

Here is a link to a reusable Class that uses XML configuration files to persist user options: Managing configuration settings persistence in .NET applications
 
Paszt said:
The INI approach JuggaloBrotha has shown is perfectly viable, however the new standard is XML. VB8 (framework version 2) has built-in classes that utilize XML to persist settings.

Here is a link to a reusable Class that uses XML configuration files to persist user options: Managing configuration settings persistence in .NET applications


thanx, i'd actually been meaning to research how to 'properly' go about saveing program settings since the system registry isn't recamended anymore
 
Back
Top