基于C#实现FTP下载文件
作者:芝麻粒儿
这篇文章主要为大家详细介绍了如何利用C#实现FTP下载文件,文中的示例代码讲解详细,对我们学习C#有一定的帮助,感兴趣的小伙伴可以跟随小编一起了解一下
实践过程
效果
代码
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(textBox1.Text); ftpRequest.Credentials = new NetworkCredential(textBox2.Text,textBox3.Text); FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse(); Stream data = ftpResponse.GetResponseStream(); string str = textBox1.Text.Substring(textBox1.Text.LastIndexOf("/"), textBox1.Text.Length - textBox1.Text.LastIndexOf("/")); string SavePath = str; if (File.Exists(SavePath)) { File.Delete(str); } byte[] buffer = new byte[4096]; FileStream stream =new FileStream(SavePath,FileMode.Create); int count = 0; do { count = data.Read(buffer, 0, buffer.Length); if (count > 0) { stream.Write(buffer, 0, count); } } while (count > 0); ftpResponse.Close(); stream.Close(); } }
partial class Form1 { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// 清理所有正在使用的资源。 /// </summary> /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows 窗体设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要 /// 使用代码编辑器修改此方法的内容。 /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.button1 = new System.Windows.Forms.Button(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.textBox2 = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.textBox3 = new System.Windows.Forms.TextBox(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.新建NToolStripButton = new System.Windows.Forms.ToolStripButton(); this.打开OToolStripButton = new System.Windows.Forms.ToolStripButton(); this.保存SToolStripButton = new System.Windows.Forms.ToolStripButton(); this.打印PToolStripButton = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator = new System.Windows.Forms.ToolStripSeparator(); this.剪切UToolStripButton = new System.Windows.Forms.ToolStripButton(); this.复制CToolStripButton = new System.Windows.Forms.ToolStripButton(); this.粘贴PToolStripButton = new System.Windows.Forms.ToolStripButton(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.帮助LToolStripButton = new System.Windows.Forms.ToolStripButton(); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.文件FToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.新建NToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.打开OToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.保存SToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.另存为AToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.打印PToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.打印预览VToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); this.退出XToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.编辑EToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.撤消UToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.重复RToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); this.剪切TToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.复制CToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.粘贴PToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); this.全选AToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.工具TToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.自定义CToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.选项OToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.帮助HToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.内容CToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.索引IToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.搜索SToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.关于AToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(178, 162); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 0; this.button1.Text = "下载"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(108, 76); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(145, 21); this.textBox1.TabIndex = 1; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(21, 79); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(83, 12); this.label1.TabIndex = 2; this.label1.Text = "FTP服务器路径"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(7, 106); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(95, 12); this.label2.TabIndex = 4; this.label2.Text = "FTP服务器用户名"; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(108, 103); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(145, 21); this.textBox2.TabIndex = 3; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(21, 133); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(83, 12); this.label3.TabIndex = 6; this.label3.Text = "FTP服务器密码"; // // textBox3 // this.textBox3.Location = new System.Drawing.Point(108, 130); this.textBox3.Name = "textBox3"; this.textBox3.Size = new System.Drawing.Size(145, 21); this.textBox3.TabIndex = 5; // // toolStrip1 // this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.新建NToolStripButton, this.打开OToolStripButton, this.保存SToolStripButton, this.打印PToolStripButton, this.toolStripSeparator, this.剪切UToolStripButton, this.复制CToolStripButton, this.粘贴PToolStripButton, this.toolStripSeparator1, this.帮助LToolStripButton}); this.toolStrip1.Location = new System.Drawing.Point(0, 24); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(276, 25); this.toolStrip1.TabIndex = 7; this.toolStrip1.Text = "toolStrip1"; // // 新建NToolStripButton // this.新建NToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.新建NToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("新建NToolStripButton.Image"))); this.新建NToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.新建NToolStripButton.Name = "新建NToolStripButton"; this.新建NToolStripButton.Size = new System.Drawing.Size(23, 22); this.新建NToolStripButton.Text = "新建(&N)"; // // 打开OToolStripButton // this.打开OToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.打开OToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("打开OToolStripButton.Image"))); this.打开OToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.打开OToolStripButton.Name = "打开OToolStripButton"; this.打开OToolStripButton.Size = new System.Drawing.Size(23, 22); this.打开OToolStripButton.Text = "打开(&O)"; // // 保存SToolStripButton // this.保存SToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.保存SToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("保存SToolStripButton.Image"))); this.保存SToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.保存SToolStripButton.Name = "保存SToolStripButton"; this.保存SToolStripButton.Size = new System.Drawing.Size(23, 22); this.保存SToolStripButton.Text = "保存(&S)"; // // 打印PToolStripButton // this.打印PToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.打印PToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("打印PToolStripButton.Image"))); this.打印PToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.打印PToolStripButton.Name = "打印PToolStripButton"; this.打印PToolStripButton.Size = new System.Drawing.Size(23, 22); this.打印PToolStripButton.Text = "打印(&P)"; // // toolStripSeparator // this.toolStripSeparator.Name = "toolStripSeparator"; this.toolStripSeparator.Size = new System.Drawing.Size(6, 25); // // 剪切UToolStripButton // this.剪切UToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.剪切UToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("剪切UToolStripButton.Image"))); this.剪切UToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.剪切UToolStripButton.Name = "剪切UToolStripButton"; this.剪切UToolStripButton.Size = new System.Drawing.Size(23, 22); this.剪切UToolStripButton.Text = "剪切(&U)"; // // 复制CToolStripButton // this.复制CToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.复制CToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("复制CToolStripButton.Image"))); this.复制CToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.复制CToolStripButton.Name = "复制CToolStripButton"; this.复制CToolStripButton.Size = new System.Drawing.Size(23, 22); this.复制CToolStripButton.Text = "复制(&C)"; // // 粘贴PToolStripButton // this.粘贴PToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.粘贴PToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("粘贴PToolStripButton.Image"))); this.粘贴PToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.粘贴PToolStripButton.Name = "粘贴PToolStripButton"; this.粘贴PToolStripButton.Size = new System.Drawing.Size(23, 22); this.粘贴PToolStripButton.Text = "粘贴(&P)"; // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); // // 帮助LToolStripButton // this.帮助LToolStripButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.帮助LToolStripButton.Image = ((System.Drawing.Image)(resources.GetObject("帮助LToolStripButton.Image"))); this.帮助LToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta; this.帮助LToolStripButton.Name = "帮助LToolStripButton"; this.帮助LToolStripButton.Size = new System.Drawing.Size(23, 22); this.帮助LToolStripButton.Text = "帮助(&L)"; // // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.文件FToolStripMenuItem, this.编辑EToolStripMenuItem, this.工具TToolStripMenuItem, this.帮助HToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(276, 24); this.menuStrip1.TabIndex = 8; this.menuStrip1.Text = "menuStrip1"; // // 文件FToolStripMenuItem // this.文件FToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.新建NToolStripMenuItem, this.打开OToolStripMenuItem, this.toolStripSeparator2, this.保存SToolStripMenuItem, this.另存为AToolStripMenuItem, this.toolStripSeparator3, this.打印PToolStripMenuItem, this.打印预览VToolStripMenuItem, this.toolStripSeparator4, this.退出XToolStripMenuItem}); this.文件FToolStripMenuItem.Name = "文件FToolStripMenuItem"; this.文件FToolStripMenuItem.Size = new System.Drawing.Size(59, 20); this.文件FToolStripMenuItem.Text = "文件(&F)"; // // 新建NToolStripMenuItem // this.新建NToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("新建NToolStripMenuItem.Image"))); this.新建NToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.新建NToolStripMenuItem.Name = "新建NToolStripMenuItem"; this.新建NToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); this.新建NToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.新建NToolStripMenuItem.Text = "新建(&N)"; // // 打开OToolStripMenuItem // this.打开OToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("打开OToolStripMenuItem.Image"))); this.打开OToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.打开OToolStripMenuItem.Name = "打开OToolStripMenuItem"; this.打开OToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); this.打开OToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.打开OToolStripMenuItem.Text = "打开(&O)"; // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; this.toolStripSeparator2.Size = new System.Drawing.Size(150, 6); // // 保存SToolStripMenuItem // this.保存SToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("保存SToolStripMenuItem.Image"))); this.保存SToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.保存SToolStripMenuItem.Name = "保存SToolStripMenuItem"; this.保存SToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); this.保存SToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.保存SToolStripMenuItem.Text = "保存(&S)"; // // 另存为AToolStripMenuItem // this.另存为AToolStripMenuItem.Name = "另存为AToolStripMenuItem"; this.另存为AToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.另存为AToolStripMenuItem.Text = "另存为(&A)"; // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; this.toolStripSeparator3.Size = new System.Drawing.Size(150, 6); // // 打印PToolStripMenuItem // this.打印PToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("打印PToolStripMenuItem.Image"))); this.打印PToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.打印PToolStripMenuItem.Name = "打印PToolStripMenuItem"; this.打印PToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P))); this.打印PToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.打印PToolStripMenuItem.Text = "打印(&P)"; // // 打印预览VToolStripMenuItem // this.打印预览VToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("打印预览VToolStripMenuItem.Image"))); this.打印预览VToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.打印预览VToolStripMenuItem.Name = "打印预览VToolStripMenuItem"; this.打印预览VToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.打印预览VToolStripMenuItem.Text = "打印预览(&V)"; // // toolStripSeparator4 // this.toolStripSeparator4.Name = "toolStripSeparator4"; this.toolStripSeparator4.Size = new System.Drawing.Size(150, 6); // // 退出XToolStripMenuItem // this.退出XToolStripMenuItem.Name = "退出XToolStripMenuItem"; this.退出XToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.退出XToolStripMenuItem.Text = "退出(&X)"; // // 编辑EToolStripMenuItem // this.编辑EToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.撤消UToolStripMenuItem, this.重复RToolStripMenuItem, this.toolStripSeparator5, this.剪切TToolStripMenuItem, this.复制CToolStripMenuItem, this.粘贴PToolStripMenuItem, this.toolStripSeparator6, this.全选AToolStripMenuItem}); this.编辑EToolStripMenuItem.Name = "编辑EToolStripMenuItem"; this.编辑EToolStripMenuItem.Size = new System.Drawing.Size(59, 20); this.编辑EToolStripMenuItem.Text = "编辑(&E)"; // // 撤消UToolStripMenuItem // this.撤消UToolStripMenuItem.Name = "撤消UToolStripMenuItem"; this.撤消UToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Z))); this.撤消UToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.撤消UToolStripMenuItem.Text = "撤消(&U)"; // // 重复RToolStripMenuItem // this.重复RToolStripMenuItem.Name = "重复RToolStripMenuItem"; this.重复RToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Y))); this.重复RToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.重复RToolStripMenuItem.Text = "重复(&R)"; // // toolStripSeparator5 // this.toolStripSeparator5.Name = "toolStripSeparator5"; this.toolStripSeparator5.Size = new System.Drawing.Size(150, 6); // // 剪切TToolStripMenuItem // this.剪切TToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("剪切TToolStripMenuItem.Image"))); this.剪切TToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.剪切TToolStripMenuItem.Name = "剪切TToolStripMenuItem"; this.剪切TToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); this.剪切TToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.剪切TToolStripMenuItem.Text = "剪切(&T)"; // // 复制CToolStripMenuItem // this.复制CToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("复制CToolStripMenuItem.Image"))); this.复制CToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.复制CToolStripMenuItem.Name = "复制CToolStripMenuItem"; this.复制CToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); this.复制CToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.复制CToolStripMenuItem.Text = "复制(&C)"; // // 粘贴PToolStripMenuItem // this.粘贴PToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("粘贴PToolStripMenuItem.Image"))); this.粘贴PToolStripMenuItem.ImageTransparentColor = System.Drawing.Color.Magenta; this.粘贴PToolStripMenuItem.Name = "粘贴PToolStripMenuItem"; this.粘贴PToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); this.粘贴PToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.粘贴PToolStripMenuItem.Text = "粘贴(&P)"; // // toolStripSeparator6 // this.toolStripSeparator6.Name = "toolStripSeparator6"; this.toolStripSeparator6.Size = new System.Drawing.Size(150, 6); // // 全选AToolStripMenuItem // this.全选AToolStripMenuItem.Name = "全选AToolStripMenuItem"; this.全选AToolStripMenuItem.Size = new System.Drawing.Size(153, 22); this.全选AToolStripMenuItem.Text = "全选(&A)"; // // 工具TToolStripMenuItem // this.工具TToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.自定义CToolStripMenuItem, this.选项OToolStripMenuItem}); this.工具TToolStripMenuItem.Name = "工具TToolStripMenuItem"; this.工具TToolStripMenuItem.Size = new System.Drawing.Size(59, 20); this.工具TToolStripMenuItem.Text = "工具(&T)"; // // 自定义CToolStripMenuItem // this.自定义CToolStripMenuItem.Name = "自定义CToolStripMenuItem"; this.自定义CToolStripMenuItem.Size = new System.Drawing.Size(124, 22); this.自定义CToolStripMenuItem.Text = "自定义(&C)"; // // 选项OToolStripMenuItem // this.选项OToolStripMenuItem.Name = "选项OToolStripMenuItem"; this.选项OToolStripMenuItem.Size = new System.Drawing.Size(124, 22); this.选项OToolStripMenuItem.Text = "选项(&O)"; // // 帮助HToolStripMenuItem // this.帮助HToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.内容CToolStripMenuItem, this.索引IToolStripMenuItem, this.搜索SToolStripMenuItem, this.toolStripSeparator7, this.关于AToolStripMenuItem}); this.帮助HToolStripMenuItem.Name = "帮助HToolStripMenuItem"; this.帮助HToolStripMenuItem.Size = new System.Drawing.Size(59, 20); this.帮助HToolStripMenuItem.Text = "帮助(&H)"; // // 内容CToolStripMenuItem // this.内容CToolStripMenuItem.Name = "内容CToolStripMenuItem"; this.内容CToolStripMenuItem.Size = new System.Drawing.Size(130, 22); this.内容CToolStripMenuItem.Text = "内容(&C)"; // // 索引IToolStripMenuItem // this.索引IToolStripMenuItem.Name = "索引IToolStripMenuItem"; this.索引IToolStripMenuItem.Size = new System.Drawing.Size(130, 22); this.索引IToolStripMenuItem.Text = "索引(&I)"; // // 搜索SToolStripMenuItem // this.搜索SToolStripMenuItem.Name = "搜索SToolStripMenuItem"; this.搜索SToolStripMenuItem.Size = new System.Drawing.Size(130, 22); this.搜索SToolStripMenuItem.Text = "搜索(&S)"; // // toolStripSeparator7 // this.toolStripSeparator7.Name = "toolStripSeparator7"; this.toolStripSeparator7.Size = new System.Drawing.Size(127, 6); // // 关于AToolStripMenuItem // this.关于AToolStripMenuItem.Name = "关于AToolStripMenuItem"; this.关于AToolStripMenuItem.Size = new System.Drawing.Size(130, 22); this.关于AToolStripMenuItem.Text = "关于(&A)..."; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(276, 197); this.Controls.Add(this.toolStrip1); this.Controls.Add(this.menuStrip1); this.Controls.Add(this.label3); this.Controls.Add(this.textBox3); this.Controls.Add(this.label2); this.Controls.Add(this.textBox2); this.Controls.Add(this.label1); this.Controls.Add(this.textBox1); this.Controls.Add(this.button1); this.MainMenuStrip = this.menuStrip1; this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "从FTP下载文件"; this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Button button1; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ToolStripButton 新建NToolStripButton; private System.Windows.Forms.ToolStripButton 打开OToolStripButton; private System.Windows.Forms.ToolStripButton 保存SToolStripButton; private System.Windows.Forms.ToolStripButton 打印PToolStripButton; private System.Windows.Forms.ToolStripSeparator toolStripSeparator; private System.Windows.Forms.ToolStripButton 剪切UToolStripButton; private System.Windows.Forms.ToolStripButton 复制CToolStripButton; private System.Windows.Forms.ToolStripButton 粘贴PToolStripButton; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; private System.Windows.Forms.ToolStripButton 帮助LToolStripButton; private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem 文件FToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 新建NToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 打开OToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; private System.Windows.Forms.ToolStripMenuItem 保存SToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 另存为AToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripMenuItem 打印PToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 打印预览VToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; private System.Windows.Forms.ToolStripMenuItem 退出XToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 编辑EToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 撤消UToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 重复RToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator5; private System.Windows.Forms.ToolStripMenuItem 剪切TToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 复制CToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 粘贴PToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator6; private System.Windows.Forms.ToolStripMenuItem 全选AToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 工具TToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 自定义CToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 选项OToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 帮助HToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 内容CToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 索引IToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 搜索SToolStripMenuItem; private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; private System.Windows.Forms.ToolStripMenuItem 关于AToolStripMenuItem; }
以上就是基于C#实现FTP下载文件的详细内容,更多关于C# FTP下载文件的资料请关注脚本之家其它相关文章!