易截截图软件、单文件、免安装、纯绿色、仅160KB

【转】C#创建网站方法(一)

1、引用的空间:
using System.DirectoryServices;
using System.ServiceProcess;
2、调用
private void button1_Click(object sender, EventArgs e)
{
String webSiteName = "默认网站";
String pathToRoot = @"C:\Inetpub\wwwroot";
CreateWebSite(webSiteName,"80", pathToRoot);
}
3、方法
private void CreateWebSite(string webSiteName, string webSitePort, string pathToRoot)
{
//站点名称和物理路径
DirectoryEntry root = new DirectoryEntry("IIS://localhost/W3SVC");// Find unused ID value for new web site
int siteID = 1;
//得到现有的站点标识
foreach (DirectoryEntry entry in root.Children)
{
if (entry.SchemaClassName == "IIsWebServer")
{
int ID = Convert.ToInt32(entry.Name);
if (ID >= siteID)
{
siteID = ID + 1;
}
}
}
//利用配置文件的做法创建站点,需要先停止原来的服务,以便能够顺利写入数据
label1.Text = "正在停止服务……";
Application.DoEvents();
System.ServiceProcess.ServiceController mobServiceController3 = new System.ServiceProcess.ServiceController("IISAdmin");
foreach (System.ServiceProcess.ServiceController dependentService in mobServiceController3.DependentServices)
{
switch (dependentService.Status)
{
case ServiceControllerStatus.Stopped:
break;
case ServiceControllerStatus.StopPending:
dependentService.WaitForStatus(ServiceControllerStatus.Stopped);
break;
default:
dependentService.Stop();
dependentService.WaitForStatus(ServiceController


相关文档:

C# 回滚1

c#事务回滚(转)
作者:xue5ya  来源:博客园  发布时间:2009-03-20 16:08  阅读:263 次  原文链接   [收藏]  
Code
public void UpdateContactTableByDataSet(DataSet ds,string strTblName) 

    ......

C#基于TCP的Socket通信


   
TCP协议是一个基本的网络协议,基本上所有的网络服务都是基于TCP协议的,如HTTP,FTP等等,所以要了解网络编程就必须了解基于TCP协议的编
程。然而TCP协议是一个庞杂的体系,要彻底的弄清楚它的实现不是一天两天的功夫,所幸的是在。net
framework环境下,我们不必要去追究TCP协议底层的实现,一样 ......

C# 操作 XML 步骤

1.添加命名空间引用
using System.Xml;
2.新建xml实例
public XmlDocument objXmlDoc = new XmlDocument();
3.加载Xml文档
string path=Server.Mappath("demo.xml");//得到文档路径
objXmlDoc.Load(path);//加载文档
4.查找要进行操作的结点
objXmlDoc.SelectNodes(xpath);//得到结点集合
objXmlDoc.SelectSingleN ......

提高c#的要点



提高C#编程水平的50个要点


1.总是用属性 (Property) 来代替可访问的数据成员
2.在  readonly 和 const 之间,优先使用 readonly
3.在 as 和 强制类型转换之间,优先使用 as 操作符
4.使用条件属性 (Conditional Attributes ......

GDI+入门(C#高速处理版本)

首先感谢CSDN的朋友laviewpbt为我给我的建议。
laviewpbt提出使用getpixel处理速度太慢,上不了档次。
这里我再给大家写两种处理速度更快的图形处理方式。
下面是个内存操作灰度的程序:
bmp = new Bitmap(Application.StartupPath + "\\1.jpg");
            ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号