|
发表于 2020-10-17 12:45:01
|
显示全部楼层
1.添加System.DirectoryServices
2.using System.DirectoryServices;
3.在代码事件中如下:
protected void BT_submit_Click(object sender,EventArgs e)
{
string _server = "localhost";
string _website = "1";
string strPath = "IIS://" + _server + "/W3SVC/" + _website +"/ROOT";
dirroot = new DirectoryEntry(strPath);
DirectoryEntry newVirDir = dirroot.Children.Add("MyNewSite3", "IIsWebVirtualDir");
Response.Write(dirroot.Name);
newVirDir.Invoke("AppCreate", true);
newVirDir.CommitChanges();
dirroot.CommitChanges();
Response.Write(newVirDir.Name+"创建成功"+newVirDir.Path);
} |
|