void Main()
{
using (ServerManager serverManager = new ServerManager())
{
var config = serverManager.GetWebConfiguration("SGSM");
ConfigurationSection defaultDocumentSection = config.GetSection("system.webServer/defaultDocument");
defaultDocumentSection["enabled"] = true;
ConfigurationElementCollection filesCollection = defaultDocumentSection.GetCollection("files");
ConfigurationElement addElement = filesCollection.CreateElement("add");
addElement["value"] = @"myhome.html";
filesCollection.AddAt(0, addElement);
serverManager.CommitChanges();
}
using (ServerManager serverManager = new ServerManager())
{
var webConfig = serverManager.GetWebConfiguration("SGSM");
var section = webConfig.GetSection("system.webServer/defaultDocument");
foreach (ConfigurationElement item in section.GetCollection("files"))
{
var x = item["value"];
Console.WriteLine(x);
}
}
}
// Define other methods and classes here
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!