|
Listing 3-12 extracted from chapter Build, deploy and configure your .NET applications
Listing 3-11< > Listing 3-13
This listing can be compiled with the command line: csc.exe /out:MyApp.exe /target:exe Example_3_12_to_rename_MyApp.cs Errors: 0 Warnings: 0
Example_3_12_to_rename_MyApp.cs
using System.Configuration;
class Program {
static void Main() {
Configuration appCfg = ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
AppSettingsSection appSettings = appCfg.AppSettings;
int myInt;
if (int.TryParse( appSettings.Settings["MyInt"].Value, out myInt)) {
System.Console.WriteLine(myInt);
myInt *= 10;
appSettings.Settings["MyInt"].Value = myInt.ToString();
appCfg.Save();
}
}
}
Copyright Patrick Smacchia 2006 2007
|