Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I can read Configuration file using

AppSettingsReader.GetValue(key, type);

 

But, I want to write value corresponding the key.

I counldn't find method like

AppSettingsWriter.WriteValue(key, type);

 

How can I do this? Is there api doning this?

Sun Certified Web component Developer,

Microsoft Certified Solution Developer .NET,

Software Engineer

  • 2 years later...
Posted

Great question!

Although I think you wrote this during the 1.0 or 1.1 days 2.0 is supposed to simplify this process.

 

Acoording to msdn you can do the following:

 

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
               config.AppSettings.Settings["mySetting"].Value = "myNewValue";
               config.Save(ConfigurationSaveMode.Modified,true);
               ConfigurationManager.RefreshSection("appSettings");

 

But I have no luck with this. No errors, just no writing to the config file.

I am in VS05 writing a 2.0 win form application.

 

Any suggestions?

Wanna-Be C# Superstar
Posted
It looks like you guys are using C# so my advice won't be very helpful...but if you were using VB8, I'd tell you to check out the My namespace.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...