How can Read/Write in App.Config File using C#.Net
1.Create app.config File
<add key="EMConnectionstring" value="Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source = D:EventManagementSystem.mdb" />
2. Add new reference "System.Configure" dll
using System.Configuration;
// Open App.Config of executable
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
//ConfigurationSettings.AppSettings.
string value = string.Empty;
foreach (string key in ConfigurationManager.AppSettings)
{
value = ConfigurationManager.AppSettings[key].ToString();
}
config.AppSettings.Settings.Add("EMConnectionstring", value);
// Save the changes in App.config file.
config.Save(ConfigurationSaveMode.Modified);
// Force a reload of a changed section.
ConfigurationManager.RefreshSection("appSettings");
Articles
- Articles(C#.NET) (3)
- ASP.NET (6)
- Asp.Net(Email) (1)
- Asp.net(Image) (2)
- Asp.Net(Web.Config) (2)
- C#.NET (5)
- C#.NET Threading (3)
- C#.NET(ASP.NET) (4)
- Comments in PHP (1)
- Encryption In PHP (1)
- iPhone (Articles) (1)
- JavaScript (1)
- Json with PHP (1)
- LINQ (1)
- PHP (2)
- PHP Constant (1)
- PHP Operators (1)
- PHP Print Command (1)
- PHP Tutorial (2)
- Strings In PHP (1)
- Variable Declaration In PHP (1)
- WPF (1)
- XAML (2)
About Me
Help Link
Followers
Posted by
Sreejith A.K
Friday, August 28, 2009
comments (0)
Subscribe to:
Posts (Atom)