当前位置:web 服务器 > IIS >>

C#操作IIS的代码

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

补充:软件开发 , C# ,
Apache
IIS
Nginx
Tomcat
如果你遇到web 服务器难题:
访问www.zzzyk.com 试试
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,