程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> C#操作IIS的代碼

C#操作IIS的代碼

編輯:C#入門知識

using System;
using System.DirectoryServices;
using System.Collections;

namespace IIS6
{
    /// <summary>
    /// IISWebServer的狀態
    /// </summary>
    public enum IISServerState
    {
        /// <summary>
        ///
        /// </summary>
        Starting = 1,
        /// <summary>
        ///
        /// </summary>
        Started = 2,
        /// <summary>
        ///
        /// </summary>
        Stopping = 3,
        /// <summary>
        ///
        /// </summary>
        Stopped = 4,
        /// <summary>
        ///
        /// </summary>
        Pausing = 5,
        /// <summary>
        ///
        /// </summary>
        Paused = 6,
        /// <summary>
        ///
        /// </summary>
        Continuing = 7
    }
}


IISWebServer
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

using System.DirectoryServices;

namespace IIS6
{
    /// <summary>
    /// IISWebServer
    /// </summary>
    public class IISWebServer
    {
       
        /// <summary>
        ///
        /// </summary>
        internal int index = -1;
       
        /// <summary>
        ///
        /// </summary>
        public IISWebVirtualDirCollection WebVirtualDirs;
       
        /// <summary>
        /// 網站說明
        /// </summary>
        public string ServerComment = "Way";
       
        /// <summary>
        /// 腳本支持
        /// </summary>
        public bool AccessScript = true;
       
        /// <summary>
        /// 讀取
        /// </summary>
        public bool AccessRead = true;
       
        /// <summary>
        /// 物理路徑
        /// </summary>
        public string Path = @"c:";
       
        /// <summary>
        /// 端口
        /// </summary>
        public int Port = 80;
       
        /// <summary>
        /// 目錄浏覽
        /// </summary>
        public bool EnableDirBrowsing = false;
       
        /// <summary>
        /// 默認文檔
        /// </summary>
        public string DefaultDoc = "index.aspx";
       
        /// <summary>
        /// 使用默認文檔
        /// </summary>
        public bool EnableDefaultDoc = true;

       
        /// <summary>
        /// IISWebServer的狀態
        /// </summary>
        public IISServerState ServerState
        {
            get
            {
                DirectoryEntry server = IISManagement.returnIISWebserver(this.index);
                if (server == null)
                    throw (new Exception("找不到此IISWebServer"));
                switch (server.Properties["ServerState"][0].ToString())
                {
                    case "2":
                        return IISServerState.Started;
                    case "4":
                        return IISSe

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved