www.pudn.com > SharpDownload(FTP¼°WEBÏÂÔØ).zip > DownloadMonitor.cs


using System; 
using System.Drawing; 
using System.Collections; 
using System.ComponentModel; 
using System.Windows.Forms; 
 
namespace SharpDownload 
{ 
	///  
	/// Summary description for DownloadMonitor. 
	///  
	public class formDownloadMonitor : System.Windows.Forms.Form 
	{ 
		private System.Windows.Forms.MainMenu mainMenu; 
		private System.Windows.Forms.MenuItem menuItem3; 
		private System.Windows.Forms.MenuItem menuItemFile; 
		private System.Windows.Forms.MenuItem menuItemFileExit; 
		private System.Windows.Forms.MenuItem menuItemFileNew; 
		private System.Windows.Forms.MenuItem menuItemHelp; 
		private System.Windows.Forms.MenuItem menuItemHelpAbout; 
		private System.Windows.Forms.MenuItem menuItem1; 
		///  
		/// Required designer variable. 
		///  
		private System.ComponentModel.Container components = null; 
 
		///  
		/// Default public constructor 
		///  
		public formDownloadMonitor() 
		{ 
			// 
			// Required for Windows Form Designer support 
			// 
			InitializeComponent(); 
 
			// 
			// TODO: Add any constructor code after InitializeComponent call 
			// 
		} 
 
		///  
		/// Clean up any resources being used. 
		///  
		protected override void Dispose( bool disposing ) 
		{ 
			if( disposing ) 
			{ 
				if(components != null) 
				{ 
					components.Dispose(); 
				} 
			} 
			base.Dispose( disposing ); 
		} 
 
		#region Windows Form Designer generated code 
		///  
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor. 
		///  
		private void InitializeComponent() 
		{ 
			this.mainMenu = new System.Windows.Forms.MainMenu(); 
			this.menuItemFile = new System.Windows.Forms.MenuItem(); 
			this.menuItemFileNew = new System.Windows.Forms.MenuItem(); 
			this.menuItem3 = new System.Windows.Forms.MenuItem(); 
			this.menuItemFileExit = new System.Windows.Forms.MenuItem(); 
			this.menuItem1 = new System.Windows.Forms.MenuItem(); 
			this.menuItemHelp = new System.Windows.Forms.MenuItem(); 
			this.menuItemHelpAbout = new System.Windows.Forms.MenuItem(); 
			//  
			// mainMenu 
			//  
			this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { 
																					 this.menuItemFile, 
																					 this.menuItemHelp}); 
			//  
			// menuItemFile 
			//  
			this.menuItemFile.Index = 0; 
			this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { 
																						 this.menuItemFileNew, 
																						 this.menuItem3, 
																						 this.menuItemFileExit, 
																						 this.menuItem1}); 
			this.menuItemFile.Text = "&File"; 
			//  
			// menuItemFileNew 
			//  
			this.menuItemFileNew.Index = 0; 
			this.menuItemFileNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN; 
			this.menuItemFileNew.Text = "&New Download..."; 
			this.menuItemFileNew.Click += new System.EventHandler(this.menuItemFileNew_Click); 
			//  
			// menuItem3 
			//  
			this.menuItem3.Index = 1; 
			this.menuItem3.Text = "-"; 
			//  
			// menuItemFileExit 
			//  
			this.menuItemFileExit.Index = 2; 
			this.menuItemFileExit.Text = "E&xit"; 
			this.menuItemFileExit.Click += new System.EventHandler(this.menuItemFileExit_Click); 
			//  
			// menuItem1 
			//  
			this.menuItem1.Index = 3; 
			this.menuItem1.Text = "HTTP TEST (Remove!)"; 
			this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click); 
			//  
			// menuItemHelp 
			//  
			this.menuItemHelp.Index = 1; 
			this.menuItemHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { 
																						 this.menuItemHelpAbout}); 
			this.menuItemHelp.Text = "&Help"; 
			//  
			// menuItemHelpAbout 
			//  
			this.menuItemHelpAbout.Index = 0; 
			this.menuItemHelpAbout.Text = "&About"; 
			this.menuItemHelpAbout.Click += new System.EventHandler(this.menuItemHelpAbout_Click); 
			//  
			// formDownloadMonitor 
			//  
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); 
			this.ClientSize = new System.Drawing.Size(560, 273); 
			this.Menu = this.mainMenu; 
			this.Name = "formDownloadMonitor"; 
			this.Text = "DownloadMonitor"; 
			this.Load += new System.EventHandler(this.formDownloadMonitor_Load); 
 
		} 
		#endregion 
 
		///  
		/// The main entry point for the application. 
		///  
		[STAThread] 
		static void Main()  
		{ 
			Application.Run(new formDownloadMonitor()); 
		} 
 
		private void formDownloadMonitor_Load(object sender, System.EventArgs e) 
		{ 
		 
		} 
 
		private void menuItemHelpAbout_Click(object sender, System.EventArgs e) 
		{ 
			// Show the about dialog 
			formHelpAbout formAbout = new formHelpAbout(); 
			formAbout.ShowDialog(this); 
		} 
 
		private void menuItemFileNew_Click(object sender, System.EventArgs e) 
		{ 
			// Show the file download dialog 
			formFileDownload formDownload = new formFileDownload(); 
			formDownload.Show(); 
		} 
 
		private void menuItemFileExit_Click(object sender, System.EventArgs e) 
		{ 
			Application.Exit(); 
		} 
 
		private void menuItem1_Click(object sender, System.EventArgs e) 
		{ 
			HttpClient httpClient = new HttpClient(); 
			httpClient.Server = "download.microsoft.com"; //"www.microsoft.com"; 
			httpClient.RemotePath = "/homepage/gif/bnr-microsoft.gif"; 
			httpClient.Login(); 
			//long fileSize = httpClient.GetFileSize("/warning.gif"); 
			httpClient.Download(httpClient.RemotePath, @"c:\bnr-microsoft.gif", false); 
			httpClient.Close(); 
			httpClient = null; 
			//MessageBox.Show(fileSize.ToString()); 
		} 
	} 
}