WinForm-C#操作IIS_DirectoryEntry
DirectoryEntry rootfolder = new DirectoryEntry("IIS://localhost/W3SVC/1/ROOT"); // IIS://服务器的名字/要操作的Web服务器类型/站点/站点的虚拟目录
1、创建对象:
2、修改对象:
#region 1、利用DirectoryEntry修改IIS默认站点的端口By网站端口
DirectoryEntry ent = new DirectoryEntry("IIS://localhost/w3svc"); // 得到现默认站点的IP 端口 描述
foreach (DirectoryEntry child in ent.Children)
{
if (child.SchemaClassName == "IIsWebServer" && child.Properties["ServerBindings"].Value != null && child.Properties["ServerBindings"].Value.ToString() == ":8090:") // 后台系统默认为8090端口
{
string strServerBindings = child.Properties["ServerBindings"].Value.ToString();
//解出端口Port
char[] splitChar = { ':' };
string[] strArr = strServerBindings.Split(splitChar);
string newStrServerBindings = strArr[0] + $":{txtIISConfig_FrontBackPort.Text}:" + strArr[2];
child.Properties["ServerBindings"].Value = newStrServerBindings; // 重新给端口赋值
child.CommitChanges();
}
}
#endregion 利用DirectoryEntry修改IIS默认站点的端口By网站端口
3、删除对象:
参考:
C#使用DirectoryEntry操作IIS创建网站和虚拟路径
本文来自博客园,作者:꧁执笔小白꧂,转载请注明原文链接:https://www.cnblogs.com/qq2806933146xiaobai/p/17317302.html
分类:
C#
, .Net-WinForm
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 一文读懂知识蒸馏
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
2021-04-14 Linux系统知识(二)-Root用户登录Ubuntu并且可以SSH
2021-04-14 Ubuntu20.04安装SqlServer2019教程-简洁版