资源简介
完整代码,重新编译,界面非常人性化,而且注释很清晰。能够实现登陆、匿名登陆、上传、下载、创建、删除等功能,对初学者有很好的参考价值。
代码片段和文件信息
using System;
using System.IO;
// 添加命令空间
using System.Net;
using System.Text;
using System.Windows.Forms;
namespace FTP
{
public partial class Form1 : Form
{
private const int ftpport = 21;
private string ftpUristring = null;
private NetworkCredential networkCredential;
private string currentDir = “/“;
public Form1()
{
InitializeComponent();
IPAddress[] ips = Dns.GetHostAddresses(““);
ServerIp.Text = ips[1].ToString();
ServerIp.SelectAll();
logout.Enabled = false;
FtpResources.Enabled = false;
FtpState.Enabled = false;
Upload.Enabled = false;
download.Enabled = false;
Delete.Enabled = false;
}
#region 键盘按下事件
private void tbxServerIp_KeyPress(object sender KeyPressEventArgs e)
{
// 输入用户名回车后,焦点直接转到密码文本框
if (e.KeyChar == (char)13)
{
Username.Focus();
}
}
private void tbxUsername_KeyPress(object sender KeyPressEventArgs e)
{
// 输入用户名回车后,焦点直接转到密码文本框
if (e.KeyChar == (char)13)
{
Password.Focus();
}
}
private void tbxPassword_KeyPress(object sender KeyPressEventArgs e)
{
// 输入密码回车后直接可以登录
if (e.KeyChar == (char)13)
{
login.Focus();
}
}
#endregion
// 匿名复选框Click事件
private void Anonymous_Click(object sender EventArgs e)
{
// 实名方式登录
// 此时需要输入用户名和密码
if (Anonymous.Checked == false)
{
Username.Enabled = true;
Username.Text = “user1“;
Password.Enabled = true;
Password.Text = ““;
Username.Focus();
}
// 匿名方式
else
{
Username.Text = “anonymous“;
Username.Enabled = false;
Password.Text = ““;
Password.Enabled = false;
}
}
#region 与服务器的交互
// 创建FTP连接
private FtpWebRequest CreateFtpWebRequest(string uri string requestMethod)
{
FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(uri);
request.Credentials = networkCredential;
request.KeepAlive = true;
request.UseBinary = true;
request.Method = requestMethod;
return request;
}
// 获取服务器返回的响应体
private FtpWebResponse GetFtpResponse(FtpWebRequest request)
{
FtpWebResponse response = null;
try
{
response = (FtpWebResponse)request.GetResponse();
FtpState.Items.Add(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 47616 2016-04-07 15:26 FTP\.vs\FTP\v14\.suo
文件 20480 2015-06-10 15:56 FTP\FTP\bin\Debug\FTP.exe
文件 36352 2015-06-10 15:56 FTP\FTP\bin\Debug\FTP.pdb
文件 23168 2015-06-10 20:37 FTP\FTP\bin\Debug\FTP.vshost.exe
文件 490 2013-06-18 20:28 FTP\FTP\bin\Debug\FTP.vshost.exe.manifest
文件 19968 2015-06-10 15:21 FTP\FTP\bin\Debug\FTPUpDownloader.exe
文件 42496 2015-06-10 15:21 FTP\FTP\bin\Debug\FTPUpDownloader.pdb
文件 490 2013-06-18 20:28 FTP\FTP\bin\Debug\FTPUpDownloader.vshost.exe.manifest
文件 22528 2016-04-07 10:22 FTP\FTP\bin\Release\FTP.exe
文件 30208 2016-04-07 10:22 FTP\FTP\bin\Release\FTP.pdb
文件 22696 2016-04-07 15:26 FTP\FTP\bin\Release\FTP.vshost.exe
文件 490 2015-10-30 15:19 FTP\FTP\bin\Release\FTP.vshost.exe.manifest
文件 20078 2015-06-13 12:45 FTP\FTP\Form1.cs
文件 12088 2015-06-13 12:45 FTP\FTP\Form1.Designer.cs
文件 11015 2015-06-13 09:57 FTP\FTP\Form1.resx
文件 5345 2015-06-10 15:32 FTP\FTP\FTP.csproj
文件 478 2015-06-10 15:32 FTP\FTP\FTP.csproj.user
文件 3262 2015-06-13 09:55 FTP\FTP\FTP.ico
文件 5426 2015-06-10 15:55 FTP\FTP\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6948 2015-06-10 15:33 FTP\FTP\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 398 2015-06-10 20:37 FTP\FTP\obj\x86\Debug\FTP.csproj.FileListAbsolute.txt
文件 977 2015-06-10 15:52 FTP\FTP\obj\x86\Debug\FTP.csproj.GenerateResource.Cache
文件 9180 2015-06-10 15:33 FTP\FTP\obj\x86\Debug\FTP.csprojResolveAssemblyReference.cache
文件 20480 2015-06-10 15:56 FTP\FTP\obj\x86\Debug\FTP.exe
文件 36352 2015-06-10 15:56 FTP\FTP\obj\x86\Debug\FTP.pdb
文件 180 2015-06-10 15:33 FTP\FTP\obj\x86\Debug\FTP.Properties.Resources.resources
文件 1627 2015-06-10 15:25 FTP\FTP\obj\x86\Debug\FTPUpDownloader.csproj.FileListAbsolute.txt
文件 904 2015-06-10 15:21 FTP\FTP\obj\x86\Debug\FTPUpDownloader.csproj.GenerateResource.Cache
文件 9180 2015-06-10 15:21 FTP\FTP\obj\x86\Debug\FTPUpDownloader.csprojResolveAssemblyReference.cache
文件 19968 2015-06-10 15:21 FTP\FTP\obj\x86\Debug\FTPUpDownloader.exe
............此处省略41个文件信息
- 上一篇:疯狂物联 跨阵M4物联网控制器原理图
- 下一篇:DFORRT.DLL
相关资源
- RobotDog 聊天狗
- 在局域网内多播稳定传送大文件
- 网络编程---ftp客户端程序实验报告
- Ftp.zip
- Office 2013 语言包含32、64位官方地址
- redupload多文件上传控件 dll
- 精密称重AD7730读写程序,并通过串口
- Netty+H5实现实时进度条文件上传,支持
- SpringBoot上传文件实例下载212710
- ewebeditor .net支持ie6、7、8、9 并能本地
- delphi多线程批量
- pb实现http文件功能--源代码 可以直接
- 分布式高并发上传设计思路图
- 读秀咨询页器
- 帝国cms批量上传多图
- Vsftp2.3.4 for linux
- Altium designer 6.0网址
- linux ftp服务器安装包vsftpd-1.1.3-8.i386
- 易语言实现FTP无人更新功能
- XLoader hex文件
- tftp安装包
- 利用Packet Tracer验证WWW、FTP、DNS、DHC
- stm32f10X实现SWD模式四线程序教程
- 一键FTP工具
- K8_Struts2_EXP S2-045 & 任意文件上传 201
- 新上传的毕设文献.rar
- STM32如何通过USB转串口线程序
- 2021考研数学大纲.pdf
- atftp-0.7.0-135.6.x86_64.rpm
- 易语言 通过POST向网页上传文件 模块
评论
共有 条评论