美好的一天!我想問一下,如果你知道如何修改web.config。其位於不同的文件夾..我試着用這種方法,不幸的是我沒有工作..修改web.config的數據庫連接字符串..?
// set Path to your config file
System.Configuration.ConfigurationFileMap fileMap = new ConfigurationFileMap(sWebConfig);
// open web.config
System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenMappedMachineConfiguration(fileMap);
// display message
Console.WriteLine("Updating wizardConnection string.. Please wait for a few minutes..");
// fetch WizardConnection database connection string
var Wizardsection = (ConnectionStringsSection)configuration.GetSection("WizardConnection");
// assign new value to wizardConnection.. Please make sure you have the correct database server. Just update server location, if need
Wizardsection.ConnectionStrings["WizardConnection"].ConnectionString = string.Format(@"server={0};database={1};integrated security=SSPI", sDatabaseServer, sDatabase);
configuration.Save();
希望聽到從您的到來..
問候,
鏈接更新web.config中的
我不認爲在web.config是從應用程序寫入。 – 2012-04-04 07:46:58