人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統下載站 > 技術開發教程 > 詳細頁面

構造.NET環境下的頁面下載器 (2)

構造.NET環境下的頁面下載器 (2)

更新時間:2022-09-07 文章作者:未知 信息來源:網絡 閱讀次數:

三.網頁下載器實例介紹: 
   
    最后,我就綜合以上.NET網絡編程的一些知識,向大家展示一個很好的實例。該實例是一個運用Socket的基于同步模式的客戶端應用程序,它首先通過解析服務器的IP地址建立一個終結點,同時創建一個基于流套接字的Socket連接,其運用的協議是TCP協議。通過該Socket就可以發送獲取網頁的命令,再通過該Socket獲得服務器上默認的網頁,最后通過文件流將獲得的數據寫入本機文件。這樣就完成了網頁的下載工作了,程序運行的效果如下所示: 
    
   
   
  程序的代碼如下: 
   
  using System; 
  using System.Drawing; 
  using System.Collections; 
  using System.ComponentModel; 
  using System.Windows.Forms; 
  using System.Data; 
  using System.Net; 
  using System.Net.Sockets; 
  using System.Text; 
  using System.IO; 
   
  namespace SocketSample 
  { 
   /// 

 
   /// Form1 的摘要說明。 
   /// 
 
   
   public class Form1 : System.Windows.Forms.Form 
   { 
   private System.Windows.Forms.Label label1; 
   private System.Windows.Forms.Label label2; 
   private System.Windows.Forms.Button Download; 
   private System.Windows.Forms.TextBox ServerAddress; 
   private System.Windows.Forms.TextBox Filename; 
   ///  
   /// 必需的設計器變量。 
   /// 
 
   private System.ComponentModel.Container 
   components = null; 
   public Form1() 
   { 
   // 
   // Windows 窗體設計器支持所必需的 
   // 
   InitializeComponent(); 
   
   // 
   // TODO: 在 InitializeComponent 
   // 調用后添加任何構造函數代碼 
   } 
   
   ///  
   /// 清理所有正在使用的資源。 
   /// 
 
   protected override void Dispose( bool disposing ) 
   { 
   if( disposing ) 
   { 
   if (components != null) 
   { 
   components.Dispose(); 
   } 
   } 
   base.Dispose( disposing ); 
   } 
   
   #region Windows Form Designer generated code 
   ///  
   /// 設計器支持所需的方法 - 不要使用代碼編輯器修改 
   /// 此方法的內容。 
   /// 
 
   private void InitializeComponent() 
   { 
   this.label1 = new System.Windows. 
   Forms.Label(); 
   this.label2 = new System.Windows. 
   Forms.Label(); 
   this.Download = new System.Windows. 
   Forms.Button(); 
   this.ServerAddress = new System.Windows. 
   Forms.TextBox(); 
   this.Filename = new System.Windows. 
   Forms.TextBox(); 
   this.SuspendLayout(); 
   // 
   // label1 
   // 
   this.label1.Location = new System.Drawing. 
   Point(16, 24); 
   this.label1.Name = "label1"; 
   this.label1.Size = new System.Drawing. 
   Size(80, 23); 
   this.label1.TabIndex = 0; 
   this.label1.Text = "服務器地址:"; 
   this.label1.TextAlign = System.Drawing. 
   ContentAlignment.MiddleRight; 
   // 
   // label2 
   // 
   this.label2.Location = new System.Drawing. 
   Point(16, 64); 
   this.label2.Name = "label2"; 
   this.label2.Size = new System.Drawing. 
   Size(80, 23); 
   this.label2.TabIndex = 1; 
   this.label2.Text = "本地文件名:"; 
   this.label2.TextAlign = System.Drawing. 
   ContentAlignment.MiddleRight; 
   // 
   // Download 
   // 
   this.Download.Location = new System. 
   Drawing.Point(288, 24); 
   this.Download.Name = "Download"; 
   this.Download.TabIndex = 2; 
   this.Download.Text = "開始下載"; 
   this.Download.Click += new System. 
   EventHandler(this.Download_Click); 
   // 
   // ServerAddress 
   // 
   this.ServerAddress.Location = new System. 
   Drawing.Point(96, 24); 
   this.ServerAddress.Name = "ServerAddress"; 
   this.ServerAddress.Size = new System. 
   Drawing.Size(176, 21); 
   this.ServerAddress.TabIndex = 3; 
   this.ServerAddress.Text = ""; 
   // 
   // Filename 

[1] [2]  下一頁

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 阿城市| 通州市| 乐昌市| 全州县| 宜黄县| 象山县| 黄大仙区| 大渡口区| 宁安市| 会理县| 伊吾县| 博野县| 金溪县| 云龙县| 乐至县| 梧州市| 西城区| 辉县市| 苍梧县| 松潘县| 富裕县| 宁波市| 黑河市| 连城县| 萍乡市| 邯郸市| 屏边| 美姑县| 噶尔县| 浏阳市| 廉江市| 子长县| 遵化市| 宝鸡市| 福建省| 威海市| 五原县| 永济市| 时尚| 凤城市| 天津市|