can i change app.config file so that value of key changes when MenuItem gets checked / unchecked

Posted on 2005-04-13
Last Modified: 2010-04-23
hi , this is my key in the app.config file
<add key="AppendTextBoolean" value="True" />

this is how i read it
Dim bConcatenateOutput As Boolean = System.Configuration.ConfigurationSettings.AppSettings("AppendTextBoolean")

this is the Menu_click event
Private Sub mnuAppendToOutput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAppendToOutput.Click
        If mnuAppendToOutput.Checked = True Then
            mnuAppendToOutput.Checked = False
            System.Configuration.ConfigurationSettings.AppSettings("AppendTextBoolean") = "False"
            mnuAppendToOutput.Checked = True
            System.Configuration.ConfigurationSettings.AppSettings("AppendTextBoolean") = "True"
        End If

    End Sub

can i set the value of the Key to to change, because currently it says it is read only when i try to run the above code
Question by:jxharding
    LVL 25

    Expert Comment

    Hi Jxharding how are you?

    yes you can,

    something like

    dim ds as new dataset

    ds.ReadXml(Application.StartupPath & "\yourexename.exe.config")
    ds.Tables(1).Rows(0).Item(1) = "False"
    LVL 25

    Accepted Solution

    sorry pressed submit to soon :-)

    dim ds as new dataset

    ds.ReadXml(Application.StartupPath & "\yourexename.exe.config")
    ds.Tables(1).Rows(0).Item(1) = "False"
    ds.WriteXml(Application.StartupPath & "\yourexename.exe.config")

    Author Comment

    hi ronald, i'm doing great thanks!

    is there an easy way perhaps of reading the value when the application starts?
    because currently i'll prob have to read it into a dataset, then make a dataview,sort it / filter it
    locate the key i need e.g. MyBoolean , and then set the menu item to checked or not.

    thanks for the help!

    Author Comment

    please ignore last comment from myself, it was really stupid of myself. i haven't done this in a while.

    thanks for the help again!

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now