Main()
{
Configuration config = OpenConfigFile(Server.MapPath("~/web.config"));
Configuration config = OpenConfigFile(Server.MapPath("~/web.config"));
config.AppSettings.Settings["XmlFile"].Value
= "UrlRoute"+(Convert.ToInt32(fileno)+1).ToString()+".xml";
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
}
}
public static Configuration OpenConfigFile(string configPath)
{
var configFile = new FileInfo(configPath);
var vdm = new VirtualDirectoryMapping(configFile.DirectoryName, true, configFile.Name);
var wcfm = new WebConfigurationFileMap();
wcfm.VirtualDirectories.Add("/",
vdm);
return WebConfigurationManager.OpenMappedWebConfiguration(wcfm,
"/");
}
No comments:
Post a Comment