通过Process.Start启动,VS自带程序WebDev.WebServer40.EXE

在内网架设网站时,为安装IIS条件下用VS自带的小程序来测试效果非常不错!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace WebServer
{
public partial class FormApp : Form
{
public FormApp()
{
InitializeComponent();
} private void btnStart_Click(object sender, EventArgs e)
{
string _AppRoot = this.txtAppRoot.Text;
string _Port = this.txtPort.Text;
string _WebPath = this.txtWebPath.Text;
string _WebvPath = this.txtWebvPath.Text;
try
{
//简单校验
CheckBoolTxt(_AppRoot, _Port, _WebPath, _WebvPath);
string arguments = string.Format("/port:{0} /path:{1} /vpath:{2}", _Port, _WebPath, _WebvPath);
System.Diagnostics.Process.Start(_AppRoot, arguments);
this.linkLabel1.Text = string.Format("http://localhost:{0}{1}", _Port, _WebvPath);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示:");
}
} private void CheckBoolTxt(string _AppRoot, string _Port, string _WebPath, string _WebvPath)
{
if (!System.IO.File.Exists(_AppRoot))
{
throw new Exception("找不到指定程序!");
}
if (!System.Text.RegularExpressions.Regex.IsMatch(_Port, @"^(([1-6][0-5][0-5][0-3][0-5])|([1-9][0-9][0-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9])|([1-9]))$")) //^[1-6]?[\d]{0,4}$
{
throw new Exception("端口:1-65535之间未使用的端口号!");
}
if (!System.IO.Directory.Exists(_WebPath))
{
throw new Exception("物理路径不存在,请指定有效的目录!");
}
if (!_WebvPath.Contains("/"))
{
throw new Exception("虚拟目录必须以'/'开头!");
}
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();
int counts = ipEndPoints.Count<IPEndPoint>(o => o.Port == int.Parse(_Port));
if (counts > )
{
throw new Exception("端口已被占用!");
}
} private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(this.linkLabel1.Text);
}
}
}

C# 调用VS自带程序WebDev.WebServer40.EXE 源代码的更多相关文章

  1. vs2010旗舰版后,运行调试一个项目时调试不了,提示的是:无法使用“pc”附加到应用程序“webdev.webserver40.exe(PID:2260”

    具体问题描述: vs2010旗舰版后,运行调试一个项目时调试不了,能编译,按ctrl+f5 可以运行,但是就是调试就不行,提示的是:无法使用“pc”附加到应用程序“webdev.webserver40 ...

  2. 开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误

    已经解决,问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open() ...

  3. ASP.NET程序运行出现WebDev.WebServer40.exe已停止工作解决方法(netsh winsock reset)

    问题描述:在开发系统时候运行程序突然报出"WebDev.WebServer40.exe已停止工作"的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.O ...

  4. 在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误的解决办法

    问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open()处. 但是 ...

  5. WebDev.WebServer40.EXE

    http://www.cnblogs.com/tong-tong/archive/2013/05/02/3049428.html 大学玩asp.net时就发现VS在Debug时会起一个web服务,这东 ...

  6. WebDev.WebServer40.EXE命令使用

    "C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\WebDev.WebServer40.EXE&quo ...

  7. 用WebDev.WebServer40.EXE调试VS代码

    1.找到WebDev.WebServer40的录井,一般位于C:/Program Files (x86)/Common Files/Microsoft Shared/DevServer/10.0/We ...

  8. WebDev.WebServer40.exe已停止工作

    今天写程序的遇到这个错误 错误的原因是代码中有死循环

  9. VS WebDev.WebServer40

    vs2010下有一个WebDev.WebServer40工具,可以直接拿来当服务器用,这样就不用再安装iis了.位置在 C:\Program Files (x86)\Common Files\micr ...

随机推荐

  1. iOS开发密码输入数字和字母混合

    #import "TestInPut.h" @implementation TestInPut +(BOOL)judgePassWordLegal:(NSString *)pass ...

  2. sql limit offset 区别

    select * from table limit 2,1;                  //含义是跳过2条取1条数据,即读取第3条数据 select * from table limit 2 ...

  3. Oracle数据迁移expdp/impdp

    Oracle数据迁移expdp/impdp目的:指导项目侧自行进行简单的数据泵迁移工作. 本文实验环境:Oracle 11.2.0.4,利用数据库自带的scott示例用户进行试验测试. 1.首先需要创 ...

  4. redhat6.5安装ntfs-3g rpm来支持ntfs文件系统挂载

    linux安装ntfs-3g模块来支持ntfs文件系统挂载 所需包 fuse-2.9.3.tar.gz ntfs-3g_ntfsprogs-2011.4.12.tgz step1. 解压fuse-2. ...

  5. GoogleMap-------manifest文件配置

    前言:在使用GoopleMap之前需要配置manifest文件 1.这个可有可无,com.xhm.meishi是项目的包名 <!-- 声明调用这个应用需要的权限 --> <permi ...

  6. QQ宠物怀念版H5

    <QQ宠物>相伴十三载 哇!明信片邮到了!!开心ヽ(○^㉨^)ノ♪ 大乐斗Ⅱ 怀念一波...

  7. JNI动态库生成、编译、查看相关简易资料

    有一篇好博文,大家可以看下http://www.cnblogs.com/zhangweia/archive/2010/09/16/1828176.html,我这里是参考其做的另外一个javah -cl ...

  8. ios -将navigationbar的translucent属性设为No后,子控制器视图整体下移问题

    如果不将navigationbar.translucent = YES 会觉得颜色很浅,因为这是半透明状态 若navigationbar.translucent = NO,颜色问题解决,但是子控制器视 ...

  9. Laravel5.1 模型--查询作用域

    所谓的查询作用域就是允许你自定义一个查询语句 把它封装成一个方法. 1 定义一个查询作用域 定义查询作用域就是在模型中声明一个scope开头的方法: public function scopeHotA ...

  10. Gson和Fastjson的使用

    转载自:JSON技术的调研报告 一.Google的Gson包的使用简单介绍. Gson类:解析json的最基础的工具类 JsonParser类:解析器来解析JSON到JsonElements的解析树 ...