C 操作IIS方法集合

2021-09-06 14:03:24 字數 3356 閱讀 9404

如果在win8,win7情況下報錯:未知錯誤(0x80005000)

using

system;

using

system.collections;

using

system.collections.generic;

using

system.directoryservices;

using

system.linq;

using

system.net;

using

system.text;

using

system.threading.tasks;

namespace

iiscontrolhelper

catch

(exception se)

}//////

建立虛擬目錄**

/// ///

**名稱

///物理路徑

///站點+埠,如192.168.1.23:90

///是否建立新的應用程式池

///public

static

int createwebsite(string websitename, string physicalpath, string domainport,bool}}

//建立web站點

directoryentry site = (directoryentry)root.invoke("

create

", "

iiswebserver

", siteid);

site.invoke(

"put

", "

servercomment

", websitename);

site.invoke(

"put

", "

keytype

", "

iiswebserver");

site.invoke(

"put

", "

serverbindings

", domainport + ":"

); site.invoke(

"put

", "

serverstate

", 2

); site.invoke(

"put

", "

frontpageweb

", 1

); site.invoke(

"put

", "

defaultdoc

", "

default.html");

"put", "securebindings", ":443:");

site.invoke("

put", "

serverautostart

", 1

); site.invoke(

"put

", "

serversize

", 1

); site.invoke(

"setinfo");

//建立應用程式虛擬目錄

directoryentry sitevdir = site.children.add("

root

", "

iiswebvirtualdir");

sitevdir.properties[

""][0] = 2

; sitevdir.properties[

"path

"][0] =physicalpath;

sitevdir.properties[

"accessflags

"][0] = 513

; sitevdir.properties[

"frontpageweb

"][0] = 1

; sitevdir.properties[

""][0] = "

lm/w3svc/

" + siteid + "

/root";

sitevdir.properties[

""][0] = "

root";

if

sitevdir.commitchanges();

site.commitchanges();

return

siteid;

}//////

得到**的物理路徑

/// ///

**節點

///public

static

string

getwebsitephysicalpath(directoryentry rootentry)

else}}

return

physicalpath;

}//////

獲取站點名

/// public

static listgetserverbindings()

/w3svc

", hostname);

directoryentry ent = new

directoryentry(entpath);

foreach (directoryentry child in

ent.children)

else

//只有乙個繫結站點

iisinfo iisinfo = new

iisinfo();

iisinfo.domainport =serverbindingstr;

"].value.tostring();//

應用程式池

iislist.add(iisinfo);}}

}return

iislist;

}public

static

password)

catch

//(exception ex)

}//////

建立程式池後關聯相應應用程式及虛擬目錄

/// public

static

poolname)}}

}}}}

//////

判斷object物件是否為陣列

/// public

static

bool isarray(object

o)

}}

C 操作IIS方法集合

如果在win8,win7情況下報錯 未知錯誤 0x80005000 見using system using system.collections using system.collections.generic using system.directoryservices using system....

C 操作IIS方法集合

如果在win8,win7情況下報錯 未知錯誤 0x80005000 見using system using system.collections using system.collections.generic using system.directoryservices using system....

C 操作IIS方法集合

如果在win8,win7情況下報錯 未知錯誤 0x80005000 見using system using system.collections using system.collections.generic using system.directoryservices using system....