RSS订阅优然探索
你的位置:首页 » 未分类 » 正文

C# 绿色IIS

选择字号: 超大 标准 发布时间:2014-12-1 16:59:6 | 作者:admin | 0个评论 | 人浏览

 

private void button1_Click(object sender, EventArgs e)
{
    if (this.button1.Text == "启动服务")
    {
        if ((this.textBox1.Text == "") || (this.textBox1.Text == "0"))
        {
            MessageBox.Show("请输入端口");
        }
        else if (Convert.ToInt32(this.textBox1.Text) > 0xffff)
        {
            MessageBox.Show("端口范围错误!在(1~65535)之间未使用的端口.");
        }
        else if (this.textBox2.Text == "")
        {
            MessageBox.Show("请选择网站目录");
        }
        else
        {
            if (this.textBox3.Text == "")
            {
                this.textBox3.Text = "/";
            }
            if (this.comboBox1.GetItemText(this.comboBox1.SelectedItem) == "v4.0")
            {
                if (!File.Exists(@"c:\WebServer40.EXE"))
                {
                    File.WriteAllBytes(@"c:\WebServer40.EXE", Files.WebDev_WebServer40);
                }
                this.p = Process.Start(@"c:\WebServer40.EXE", "/port:" + this.textBox1.Text + " /path:\"" + this.textBox2.Text + "\" /vpath:\"" + this.textBox3.Text + "\"");
                this.pid = this.p.Id;
            }
            else
            {
                if (!File.Exists(@"c:\WebServer20.EXE"))
                {
                    File.WriteAllBytes(@"c:\WebServer20.EXE", Files.WebDev_WebServer40);
                }
                this.p = Process.Start(@"c:\WebServer20.EXE", "/port:" + this.textBox1.Text + " /path:\"" + this.textBox2.Text + "\" /vpath:\"" + this.textBox3.Text + "\"");
                this.pid = this.p.Id;
            }
            this.toolStripStatusLabel1.Text = "启动成功!";
            this.button1.Text = "停止服务";
        }
    }
    else
    {
        this.p.Kill();
        this.pid = 0;
        this.toolStripStatusLabel1.Text = "服务已经关闭!";
        this.button1.Text = "启动服务";
    }
}

 

 

标签:

猜你喜欢

发表评论

必填

选填

选填

必填,不填不让过哦,嘻嘻。

记住我,下次回复时不用重新输入个人信息

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。