hi
this code works fine and my config file changes correctly.
//Local Variable Declaration
System.Configuration.Configuration oConfig =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(
Request.ApplicationPath);
if (oConfig .AppSettings.Settings["CompanyName"] == null)
{
oConfig AppSettings.Settings.Add("CompanyName", "MyCompanyName");
oConfig .Save();
}
but when I want to use a property for this purpose Nothing happend in Config File.
// Property Declaration
private System.Configuration.Configuration _oRootConfig;
public System.Configuration.Configuration oRootConfig
{
get
{
return
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(
Request.ApplicationPath);
}
set { _oRootConfig = value; }
}
if (oRootConfig.AppSettings.Settings["CompanyName"] == null)
{
oRootConfig.AppSettings.Settings.Add("CompanyName", "MyCompanyName");
oRootConfig.Save(System.Configuration.ConfigurationSaveMode.Modified, true);
}
now i have two question:
1-why this code doesnot work ,and there
is no error.
2-if i want to programn in object oriented
manner ,what can i do to fix this property
if the problem is related to the property.
thanks