C# 调用VS自带程序WebDev.WebServer40.EXE 源代码
通过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 源代码的更多相关文章
- vs2010旗舰版后,运行调试一个项目时调试不了,提示的是:无法使用“pc”附加到应用程序“webdev.webserver40.exe(PID:2260”
具体问题描述: vs2010旗舰版后,运行调试一个项目时调试不了,能编译,按ctrl+f5 可以运行,但是就是调试就不行,提示的是:无法使用“pc”附加到应用程序“webdev.webserver40 ...
- 开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误
已经解决,问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open() ...
- ASP.NET程序运行出现WebDev.WebServer40.exe已停止工作解决方法(netsh winsock reset)
问题描述:在开发系统时候运行程序突然报出"WebDev.WebServer40.exe已停止工作"的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.O ...
- 在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误的解决办法
问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open()处. 但是 ...
- WebDev.WebServer40.EXE
http://www.cnblogs.com/tong-tong/archive/2013/05/02/3049428.html 大学玩asp.net时就发现VS在Debug时会起一个web服务,这东 ...
- WebDev.WebServer40.EXE命令使用
"C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\WebDev.WebServer40.EXE&quo ...
- 用WebDev.WebServer40.EXE调试VS代码
1.找到WebDev.WebServer40的录井,一般位于C:/Program Files (x86)/Common Files/Microsoft Shared/DevServer/10.0/We ...
- WebDev.WebServer40.exe已停止工作
今天写程序的遇到这个错误 错误的原因是代码中有死循环
- VS WebDev.WebServer40
vs2010下有一个WebDev.WebServer40工具,可以直接拿来当服务器用,这样就不用再安装iis了.位置在 C:\Program Files (x86)\Common Files\micr ...
随机推荐
- 基于AFNetworking的网络判断【原创】
首先导入AFNetworking第三方框架,然后将下面的.h和.m放在你新建的类中便可 GGNetworkJudge.h 在最后会有Singleton.h头文件代码 #import <Fou ...
- ueditor 控制上传图片的显示尺寸
使用UEditor的编辑框插入图片的时候,如果图片尺寸比较大,则图片会超出编辑器边框出现滚动条,特别不方便. 解决办法:在ueditor 的 themes 文件夹下有个iframe.css 文件,在该 ...
- 深度解析丨秒懂nova3手机上超酷炫的AR应用及开发
此前在HUAWEI nova3发布会中,相信大家都已经感受到了AR能力带来的惊喜: 现实场景召唤圣斗士,随时随地交流合影: 点击观看视频:https://v.qq.com/x/page/m1344f6 ...
- Sphinx 安装与使用(2)-- 配置Coreseek
1.必须先关闭守护进程才能做其他的操作(第一次启动不需要这一步) /usr/local/coreseek/bin/searchd --config /usr/local/coreseek/etc/te ...
- 1211日课后shell总结
1211shell 作者:高波 归档:学习笔记 2017年12月11日13:10:56 快捷键: Ctrl + 1 标题1 Ctrl + 2 标题2 Ctrl + 3 标题3 Ctrl + 4 ...
- Asteroids - poj 3041(二分图最大匹配问题)
Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 17258 Accepted: 9386 Description Be ...
- python django -5 进阶
高级知识点包括: 静态文件处理 中间件 上传图片 Admin站点 分页 使用jquery完成ajax 管理静态文件 项目中的CSS.图片.js都是静态文件 配置静态文件 在settings 文件中定义 ...
- python __new__ __init__ __del__
1.python实例化顺序是.__new__ -->__init__ --> __del__ 2.如果重写new没return,就实例化不成功
- Working with JSON in C# & VB
Introduction Whilst JSON is a compact and easy to read cross-language storage and data exchange form ...
- 关闭QQ看点
手机qq联系人 然后右上角公众号 然后看到看点 取消关注!!!