Persistent settings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    #1

    Persistent settings

    Hi



    I need to store the path to db in my app. I have used app setting for this.
    Unfortunately various clients have different db paths and I have set them up
    once on each client location. The problem is that when I send them updates
    and they uninstall the old version and reinstall the new version the setting
    is reset to my settings. This is because the old configuration file is
    deleted and replaced by the new one included in the app. Is there a way to
    have a setting that is not overwritten by an application reinstall?



    Thanks



    Regards




  • rowe_newsgroups

    #2
    Re: Persistent settings

    On Apr 28, 9:12 am, "John" <J...@nospam.in fovis.co.ukwrot e:
    Hi
    >
    I need to store the path to db in my app. I have used app setting for this.
    Unfortunately various clients have different db paths and I have set them up
    once on each client location. The problem is that when I send them updates
    and they uninstall the old version and reinstall the new version the setting
    is reset to my settings. This is because the old configuration file is
    deleted and replaced by the new one included in the app. Is there a way to
    have a setting that is not overwritten by an application reinstall?
    >
    Thanks
    >
    Regards
    I have always used a separate file for things like this - perhaps you
    could use an Xml file that is stored in the application's base
    directory. If you are worried about the sensitive nature of connection
    strings, you could even have your app encrypt/decrypt that file.

    Thanks,

    Seth Rowe

    Comment

    • John

      #3
      Re: Persistent settings

      Many thanks for that. Would be grateful for a link on how to handle xml
      files.

      Thanks

      Regards


      "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
      news:1177766237 .545191.223640@ e65g2000hsc.goo glegroups.com.. .
      On Apr 28, 9:12 am, "John" <J...@nospam.in fovis.co.ukwrot e:
      >Hi
      >>
      >I need to store the path to db in my app. I have used app setting for
      >this.
      >Unfortunatel y various clients have different db paths and I have set them
      >up
      >once on each client location. The problem is that when I send them
      >updates
      >and they uninstall the old version and reinstall the new version the
      >setting
      >is reset to my settings. This is because the old configuration file is
      >deleted and replaced by the new one included in the app. Is there a way
      >to
      >have a setting that is not overwritten by an application reinstall?
      >>
      >Thanks
      >>
      >Regards
      >
      I have always used a separate file for things like this - perhaps you
      could use an Xml file that is stored in the application's base
      directory. If you are worried about the sensitive nature of connection
      strings, you could even have your app encrypt/decrypt that file.
      >
      Thanks,
      >
      Seth Rowe
      >

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Persistent settings

        "John" <John@nospam.in fovis.co.ukschr ieb:
        I need to store the path to db in my app. I have used app setting for
        this. Unfortunately various clients have different db paths and I have set
        them up once on each client location. The problem is that when I send them
        updates and they uninstall the old version and reinstall the new version
        the setting is reset to my settings. This is because the old configuration
        file is deleted and replaced by the new one included in the app. Is there
        a way to have a setting that is not overwritten by an application
        reinstall?
        Take a look at 'My.Settings' and the "Settings" tab in "My Project" if you
        are using VS 2005.

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://classicvb.org/petition/>

        Comment

        • rowe_newsgroups

          #5
          Re: Persistent settings

          On Apr 28, 12:25 pm, "John" <J...@nospam.in fovis.co.ukwrot e:
          Many thanks for that. Would be grateful for a link on how to handle xml
          files.
          >
          Thanks
          >
          Regards
          >
          "rowe_newsgroup s" <rowe_em...@yah oo.comwrote in message
          >
          news:1177766237 .545191.223640@ e65g2000hsc.goo glegroups.com.. .
          >
          On Apr 28, 9:12 am, "John" <J...@nospam.in fovis.co.ukwrot e:
          Hi
          >
          I need to store the path to db in my app. I have used app setting for
          this.
          Unfortunately various clients have different db paths and I have set them
          up
          once on each client location. The problem is that when I send them
          updates
          and they uninstall the old version and reinstall the new version the
          setting
          is reset to my settings. This is because the old configuration file is
          deleted and replaced by the new one included in the app. Is there a way
          to
          have a setting that is not overwritten by an application reinstall?
          >
          Thanks
          >
          Regards
          >
          I have always used a separate file for things like this - perhaps you
          could use an Xml file that is stored in the application's base
          directory. If you are worried about the sensitive nature of connection
          strings, you could even have your app encrypt/decrypt that file.
          >
          Thanks,
          >
          Seth Rowe
          Here's a quick console application that briefly demonstrates how to
          use an Xml file:

          Imports System.Xml

          Module Module1

          Sub Main()
          Console.WriteLi ne("Saving Settings...")
          SaveSettings()
          System.Threadin g.Thread.Sleep( 500)
          Console.WriteLi ne(GetSetting(" ConnectionStrin g"))
          Console.Read()
          Dim fileName As String = String.Format(" C:\Document and
          Settings\{0}\De sktop\MyXmlFile .Xml", Environment.Use rName)
          If System.IO.File. Exists(fileName ) Then
          System.IO.File. Delete(fileName )
          End If
          End Sub

          Public Sub SaveSettings()
          Dim writer As XmlWriter = XmlWriter.Creat e(String.Format ("C:
          \Documents and Settings\{0}\De sktop\MyXmlFile .Xml",
          Environment.Use rName))
          writer.WriteSta rtElement("Sett ings")
          writer.WriteSta rtElement("Conn ectionString")
          writer.WriteStr ing("YourConnSt ring")
          writer.WriteEnd Element() ' ConnectionStrin g
          writer.WriteEnd Element() ' Settings
          writer.Close()
          End Sub

          Public Function GetSetting(ByVa l nodeName As String) As String
          Dim doc As New XmlDocument
          doc.Load(String .Format("C:\Doc uments and Settings\{0}\De sktop
          \MyXmlFile.Xml" , Environment.Use rName))
          Dim node As XmlNode = doc.GetElements ByTagName(nodeN ame)(0)
          Return node.InnerText
          End Function

          End Module

          Thanks,

          Seth Rowe

          Comment

          Working...