亚洲乱色熟女一区二区三区丝袜,天堂√中文最新版在线,亚洲精品乱码久久久久久蜜桃图片,香蕉久久久久久av成人,欧美丰满熟妇bbb久久久

LOGO OA教程 ERP教程 模切知識(shí)交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

[點(diǎn)晴永久免費(fèi)OA]C#動(dòng)態(tài)添加IIS個(gè)各個(gè)版本的MIME類型

admin
2022年4月19日 16:35 本文熱度 2972

主要是介紹IIS6和IIS7。IIS6主要是運(yùn)用System.DirectoryServices.dll,IIS7用到Microsoft.Web.Administration.dll,該DLL在IIS7目錄中存在,拷貝即可。


代碼如下:

/// <summary>

/// 取得IIS版本

/// </summary>

/// <returns></returns>

private int GetIISVersion()

{

DirectoryEntry getEntity = new DirectoryEntry("IIS://localhost/W3SVC/INFO");

string strVersion = getEntity.Properties["MajorIISVersionNumber"].Value.ToString();

return Convert.ToInt32(strVersion);

}


主體實(shí)現(xiàn)方法:

private void Main() {

//判斷IIS版本

int iisVersion = this.GetIISVersion();

//IIS7

if (iisVersion > 6)

{

try

{

ServerManager server = new ServerManager();

Configuration confg = server.GetWebConfiguration(webSiteName); //webSiteName站點(diǎn)名稱

ConfigurationSection section;

section = confg.GetSection("system.webServer/staticContent"); //取得MimeMap所有節(jié)點(diǎn)(路徑為:%windir%\Windows\System32\inetsrv\config\applicationHost.config)

ConfigurationElement filesElement = section.GetCollection();

ConfigurationElementCollection filesCollection = filesElement.GetCollection();

ConfigurationElement newElement = filesCollection.createElement(); //新建MimeMap節(jié)點(diǎn)

newElement.Attributes["fileExtension"].Value = this.txtName.Text;

newElement.Attributes["mimeType"].Value = this.txtMimeType.Text;

if (filesCollection.Contains(newElement))

{

MessageBox.Show("您添加的類型已存在,請(qǐng)重新添加!");

return;

}

filesCollection.Add(newElement);

server.CommitChanges(); //更改目錄

MessageBox.Show("添加成功!");

this.Close();

}

catch (Exception ex)

{

MessageBox.Show("eror:" + ex.Message.ToString());

}

}

else //IIS6

{

try

{

int id = this.GetselectIdByWebSiteName(webSiteName); //取得站點(diǎn)的標(biāo)識(shí)符ID

DirectoryEntry path = new DirectoryEntry(string.Format("IIS://localhost/w3svc/{0}/root", id));

PropertyValueCollection propValues = path.Properties["MimeMap"];

string newExtension = this.txtName.Text; //擴(kuò)展名

string newMimeType = this.txtMimeType.Text; //MIME類型

object exists = null;

foreach (object value in propValues)

{

IISOle.IISMimeType mimetypeObj = (IISOle.IISMimeType)value;

if (newExtension == mimetypeObj.Extension){exists = value;}

}

if (null != exists)

{

//propValues.Remove(exists);

MessageBox.Show("您添加的類型已存在,請(qǐng)重新添加!");

return;

}

IISOle.MimeMapClass _NewMime = new IISOle.MimeMapClass(); //新建MIME類型

_NewMime.Extension = newExtension;

_NewMime.MimeType = newMimeType;

propValues.Add(_NewMime); //添加MIME類型

path.CommitChanges(); //更改目錄

MessageBox.Show("添加成功!");

this.Close();

}

catch (Exception ex)

{

MessageBox.Show(ex.Message.ToString());

}

}

}


該文章在 2022/4/19 16:35:25 編輯過
關(guān)鍵字查詢
相關(guān)文章
正在查詢...
點(diǎn)晴ERP是一款針對(duì)中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對(duì)港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場、車隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場作業(yè)而開發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉儲(chǔ)管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲(chǔ)管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號(hào)管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved