http://www.dotblogs.com.tw/puma/archive/2008/03/05/1248.aspx

 using System;
 using System.Data;
 using System.Configuration;
 using System.Collections;
 using System.Web;
 using System.Web.Security;
 using System.Web.UI;
 using System.Web.UI.WebControls;
 using System.Web.UI.WebControls.WebParts;
 using System.Web.UI.HtmlControls;
 using System.Diagnostics;
 using System.Net;

    string URL = this.TextBox1.Text;
            bool Ok  = true;//預設URL的狀態是正常的
            WebRequest request = WebRequest.Create(URL);
            request.Proxy = null;
            try
            {           
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
               Response.Write("\n Site Exists.");
           }
           catch (Exception exc)
           {
               Response.Write("\n Site does not exists.");
               Ok = false;
           }
   
           //URL是正常運作,才抓取URL畫面
           if (Ok != false)
           {
               Process proc = new Process();
               //IECapt.exe path
               proc.StartInfo.FileName = Server.MapPath("~/IECapt.exe");
               //將取得的畫面暫存為image.png檔
              proc.StartInfo.Arguments = this.TextBox1.Text + " " + Server.MapPath("~/image.png");
              proc.Start();
              //等待IECapt程式執行完畢
              proc.WaitForExit();
              this.Image1.ImageUrl = "image.png";
          }

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 AndrewHsiao 的頭像
    AndrewHsiao

    Andrew的部落格

    AndrewHsiao 發表在 痞客邦 留言(0) 人氣()