Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Save "app.config" configuration-file does not work

Save "app.config" configuration-file does not work

Scheduled Pinned Locked Moved C#
questionhelpannouncementworkspace
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Frygreen
    wrote on last edited by
    #1

    Dear experts, I want to update the configFile "app.config", but the "Save(..)" function does not work. Surprisingly, if I use the "SaveAs(..)" function (storing the config to another file),it works

        static void Main(string\[\] args)
        {
            // Open App.Config of executable
            Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            
            // Add a new Application Setting.
            config.AppSettings.Settings.Add("Modification Date",DateTime.Now.ToLongTimeString() + " ");
    
            // This does not update the file "app.config"
            config.Save(ConfigurationSaveMode.Full);
    
            // This correctly writes the file "Test.config"
            config.SaveAs("Test.config", ConfigurationSaveMode.Full);
        }
    

    Question: What sense does the Save()-Method make? Can somebody help me? Thanks in advance

    A W 2 Replies Last reply
    0
    • F Frygreen

      Dear experts, I want to update the configFile "app.config", but the "Save(..)" function does not work. Surprisingly, if I use the "SaveAs(..)" function (storing the config to another file),it works

          static void Main(string\[\] args)
          {
              // Open App.Config of executable
              Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
              
              // Add a new Application Setting.
              config.AppSettings.Settings.Add("Modification Date",DateTime.Now.ToLongTimeString() + " ");
      
              // This does not update the file "app.config"
              config.Save(ConfigurationSaveMode.Full);
      
              // This correctly writes the file "Test.config"
              config.SaveAs("Test.config", ConfigurationSaveMode.Full);
          }
      

      Question: What sense does the Save()-Method make? Can somebody help me? Thanks in advance

      A Offline
      A Offline
      Arun Jacob
      wrote on last edited by
      #2

      Is it throwing any error?Can you check if the file is readonly

      Arun Jacob http://codepronet.blogspot.com/

      F 1 Reply Last reply
      0
      • F Frygreen

        Dear experts, I want to update the configFile "app.config", but the "Save(..)" function does not work. Surprisingly, if I use the "SaveAs(..)" function (storing the config to another file),it works

            static void Main(string\[\] args)
            {
                // Open App.Config of executable
                Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                
                // Add a new Application Setting.
                config.AppSettings.Settings.Add("Modification Date",DateTime.Now.ToLongTimeString() + " ");
        
                // This does not update the file "app.config"
                config.Save(ConfigurationSaveMode.Full);
        
                // This correctly writes the file "Test.config"
                config.SaveAs("Test.config", ConfigurationSaveMode.Full);
            }
        

        Question: What sense does the Save()-Method make? Can somebody help me? Thanks in advance

        W Offline
        W Offline
        wasifmuneer
        wrote on last edited by
        #3

        The app.config file is not updated during execution of application,but it would be writing a .xml document in the bin folder with applicationname.exe(Xml configuration File), and each time your file will be updated but not app.config

        F 1 Reply Last reply
        0
        • A Arun Jacob

          Is it throwing any error?Can you check if the file is readonly

          Arun Jacob http://codepronet.blogspot.com/

          F Offline
          F Offline
          Frygreen
          wrote on last edited by
          #4

          No exception is thrown by the Save()-Method, the file is also not "read-only"

          1 Reply Last reply
          0
          • W wasifmuneer

            The app.config file is not updated during execution of application,but it would be writing a .xml document in the bin folder with applicationname.exe(Xml configuration File), and each time your file will be updated but not app.config

            F Offline
            F Offline
            Frygreen
            wrote on last edited by
            #5

            Sorry, of course, app.config is not expected to be updated, but I expect that in the bin-directory one of the files ".xx.exe.config" or "xx.vshost.exe.Config" should be updated at least. But none of them is updated. I', puzzled. What's the purpuse of the Save()-Method? Thanks for you kind replies

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups