private void creatSite_Click(object sender, EventArgs e) { if (SiteInfo.Current.IVersion < IISVersion.IIS6) { MessageBox.Show("你的IIS版本太低,无法创建站点", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (serverComment.Text == "") { MessageBox.Show("网站描述不能为空", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); serverComment.Focus(); } else if (ip.Text == "") { MessageBox.Show("无效的IP地址", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); ip.Focus(); } else if (serverBindings.Text == "") { MessageBox.Show("无效的端口号", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); serverBindings.Focus(); } else if (webPath.Text == "") { MessageBox.Show("请选择路径", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); browser1.Focus(); } else { SiteInfo.Current.ServerComment = serverComment.Text.Trim(); SiteInfo.Current.IP = ip.Text.Trim(); SiteInfo.Current.Port = serverBindings.Text.Trim(); SiteInfo.Current.Host = host.Text.Trim(); SiteInfo.Current.WebPath = webPath.Text.Trim(); SiteInfo.Current.DefaultDoc = "Default.aspx,Default.html,index.aspx,index.html"; SiteInfo.Current.AppPool = "bbsmax_" + Guid.NewGuid().ToString().Substring(0, 8); try { UserSet();//IIS帐户设置 IISManager.CreateWebsite(); serverComment.Text = ""; host.Text = ""; webPath.Text = ""; MessageBox.Show("创建网站成功,直接点下一步进行安装。", "IIS管理器", MessageBoxButtons.OK); ListIIS(); Step2_Next.Enabled = true; Step2_Next.Focus(); } catch (Exception ex) { MessageBox.Show("创建网站失败:" + ex.Message, "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void createVirtual_Click(object sender, EventArgs e) { if (iisList.SelectedNode == null || iisList.SelectedNode.Text == SiteInfo.Current.DomainName) { MessageBox.Show("请指定一个站点或虚拟目录", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (virtualName.Text.Trim() == "") { virtualName.Focus(); MessageBox.Show("虚拟目录名称不能为空", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else if (webPath1.Text.Trim() == "") { webPath1.Focus(); MessageBox.Show("请选择路径", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { SiteInfo.Current.AppPool = "bbsmax_" + Guid.NewGuid().ToString().Substring(0, 8); SiteInfo.Current.VirPath = iisList.SelectedNode.Name; try { SiteInfo.Current.CurrentSite = new DirectoryEntry(SiteInfo.Current.VirPath); SiteInfo.Current.DefaultDoc = "Default.aspx,Default.html,index.aspx,index.html"; SiteInfo.Current.VirtualName = virtualName.Text.Trim(); SiteInfo.Current.WebPath = webPath1.Text.Trim(); try { UserSet();//IIS帐户设置 IISManager.CreateVirtual(); virtualName.Text = ""; webPath1.Text = ""; MessageBox.Show("创建虚拟目录成功。", "IIS管理器", MessageBoxButtons.OK); Step2_Next.Enabled = true; Step2_Next.Focus(); ListIIS();//刷新treeView并选中当前目录 } catch (Exception ex) { MessageBox.Show("创建虚拟目录失败:" + ex.Message, "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { MessageBox.Show("当前路径有错,创建失败。", "IIS管理器", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }