Winform中实现FTP客户端并定时扫描指定路径下文件上传到FTP服务端然后删除文件
场景
Windows10上怎样开启FTP服务:
Windows10上怎样开启FTP服务_BADAO_LIUMANG_QIZHI的博客-CSDN博客
上面在Windows上搭建FTP服务器之后,会接收客户端发来的文件并存储在指定目录下,
需要在此台服务器上再搭建一个FTP客户端实现定时扫描指定路径下的文件,并将这些文件
上传到另一个FTP服务端,上传成功之后将这些文件删除,实现文件中转操作。
找到上面搭建的网站下的FTP身份验证,双击
将匿名访问关闭,开启身份认证
注:
博客:
BADAO_LIUMANG_QIZHI的博客_霸道流氓气质_CSDN博客-C#,SpringBoot,架构之路领域博主
关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。
实现
1、Windows上创建一个新用户
控制面板-账户-家庭和其他用户-将其他人添加到这台电脑
2、选择我没有这个人的登录信息
3、选择添加一个没有账户的用户
4、然后创建用户名、密码、和安全问题等。
5、新建一个Winform项目,设计主页面布局
6、实现建立连接和列出所有文件的功能
首先新建FtpHelper工具类,该工具类来源与网络,并对其进行少量修改。
FtpHelper.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;namespace UploadFtpServerSchedule
{public class FtpHelper{#region 属性与构造函数/// <summary>/// IP地址/// </summary>public string IpAddr { get; set; }/// <summary>/// 相对路径/// </summary>public string RelatePath { get; set; }/// <summary>/// 端口号/// </summary>public string Port { get; set; }/// <summary>/// 用户名/// </summary>public string UserName { get; set; }/// <summary>/// 密码/// </summary>public string Password { get; set; }public FtpHelper(){}public FtpHelper(string ipAddr, string port, string userName, string password){this.IpAddr = ipAddr;this.Port = port;this.UserName = userName;this.Password = password;}#endregion#region 方法/// <summary>/// 下载文件/// </summary>/// <param name="filePath"></param>/// <param name="isOk"></param>public void DownLoad(string filePath, out bool isOk){string method = WebRequestMethods.Ftp.DownloadFile;var statusCode = FtpStatusCode.DataAlreadyOpen;FtpWebResponse response = callFtp(method);ReadByBytes(filePath, response, statusCode, out isOk);}public void UpLoad(string file, out bool isOk,string filename){isOk = false;FileInfo fi = new FileInfo(file);FileStream fs = fi.OpenRead();long length = fs.Length;string uri = string.Format("ftp://{0}:{1}/{2}", this.IpAddr, this.Port, filename);FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uri);request.Credentials = new NetworkCredential(UserName, Password);request.Method = WebRequestMethods.Ftp.UploadFile;request.UseBinary = true;request.ContentLength = length;request.Timeout = 10 * 1000;try{Stream stream = request.GetRequestStream();int BufferLength = 2048; //2K byte[] b = new byte[BufferLength];int i;while ((i = fs.Read(b, 0, BufferLength)) > 0){stream.Write(b, 0, i);}stream.Close();stream.Dispose();fs.Close();isOk = true;}catch (Exception ex){Console.WriteLine(ex.ToString());}finally{if (request != null){request.Abort();request = null;}}}/// <summary>/// 删除文件/// </summary>/// <param name="isOk"></param>/// <returns></returns>public string[] DeleteFile(out bool isOk){string method = WebRequestMethods.Ftp.DeleteFile;var statusCode = FtpStatusCode.FileActionOK;FtpWebResponse response = callFtp(method);return ReadByLine(response, statusCode, out isOk);}/// <summary>/// 展示目录/// </summary>public string[] ListDirectory(out bool isOk){string method = WebRequestMethods.Ftp.ListDirectoryDetails;var statusCode = FtpStatusCode.DataAlreadyOpen;FtpWebResponse response = callFtp(method);return ReadByLine(response, statusCode, out isOk);}/// <summary>/// 设置上级目录/// </summary>public void SetPrePath(){string relatePath = this.RelatePath;if (string.IsNullOrEmpty(relatePath) || relatePath.LastIndexOf("/") == 0){relatePath = "";}else{relatePath = relatePath.Substring(0, relatePath.LastIndexOf("/"));}this.RelatePath = relatePath;}#endregion#region 私有方法/// <summary>/// 调用Ftp,将命令发往Ftp并返回信息/// </summary>/// <param name="method">要发往Ftp的命令</param>/// <returns></returns>private FtpWebResponse callFtp(string method){string uri = string.Format("ftp://{0}:{1}{2}", this.IpAddr, this.Port, this.RelatePath);FtpWebRequest request; request = (FtpWebRequest)FtpWebRequest.Create(uri);request.UseBinary = true;request.UsePassive = true;request.Credentials = new NetworkCredential(UserName, Password);request.KeepAlive = false;request.Method = method;FtpWebResponse response = (FtpWebResponse)request.GetResponse();return response;}/// <summary>/// 按行读取/// </summary>/// <param name="response"></param>/// <param name="statusCode"></param>/// <param name="isOk"></param>/// <returns></returns>private string[] ReadByLine(FtpWebResponse response, FtpStatusCode statusCode, out bool isOk){List<string> lstAccpet = new List<string>();int i = 0;while (true){if (response.StatusCode == statusCode){using (StreamReader sr = new StreamReader(response.GetResponseStream())){string line = sr.ReadLine();while (!string.IsNullOrEmpty(line)){lstAccpet.Add(line);line = sr.ReadLine();}}isOk = true;break;}i++;if (i > 10){isOk = false;break;}Thread.Sleep(200);}response.Close();return lstAccpet.ToArray();}private void ReadByBytes(string filePath, FtpWebResponse response, FtpStatusCode statusCode, out bool isOk){isOk = false;int i = 0;while (true){if (response.StatusCode == statusCode){long length = response.ContentLength;int bufferSize = 2048;int readCount;byte[] buffer = new byte[bufferSize];using (FileStream outputStream = new FileStream(filePath, FileMode.Create)){using (Stream ftpStream = response.GetResponseStream()){readCount = ftpStream.Read(buffer, 0, bufferSize);while (readCount > 0){outputStream.Write(buffer, 0, readCount);readCount = ftpStream.Read(buffer, 0, bufferSize);}}}break;}i++;if (i > 10){isOk = false;break;}Thread.Sleep(200);}response.Close();}#endregion}/// <summary>/// Ftp内容类型枚举/// </summary>public enum FtpContentType{undefined = 0,file = 1,folder = 2}
}
然后按钮与Ftp服务器建立连接的点击事件
private void button_connnect_ftpserver_Click(object sender, EventArgs e){try{checkNull();if (isRight){ftpHelper = new FtpHelper(ipAddr, port, userName, password);string[] arrAccept = ftpHelper.ListDirectory(out isOk);//调用Ftp目录显示功能if (isOk){MessageBox.Show("登录成功");}}}catch (Exception ex){MessageBox.Show("登录失败:ex="+ex.Message);}}
这里调用了非空判断的校验方法checkNull
private void checkNull(){isRight = false;//非空校验ipAddr = this.textBox_addr.Text.Trim();port = this.textBox_port.Text.Trim();userName = this.textBox_name.Text.Trim();password = this.textBox_pass.Text.Trim();if (String.IsNullOrEmpty(ipAddr)){MessageBox.Show("地址不能为空");}else if (String.IsNullOrEmpty(port)){MessageBox.Show("端口不能为空");}else if (String.IsNullOrEmpty(userName)){MessageBox.Show("用户名不能为空");}else if (String.IsNullOrEmpty(password)){MessageBox.Show("密码不能为空");}else {isRight = true;}}
然后判断是否建立连接成功是通过发送列出所有文件的指令的响应来判断是否建立连接成功。
按钮列出所有文件的点击事件
private void button_listDirectory_Click(object sender, EventArgs e){checkNull();if (isRight){ftpHelper = new FtpHelper(ipAddr, port, userName, password);string[] arrAccept = ftpHelper.ListDirectory(out isOk);//调用Ftp目录显示功能if (isOk){this.textBox_log.Clear();foreach (string accept in arrAccept){string name = accept.Substring(39);this.textBox_log.AppendText(name);this.textBox_log.AppendText("\r\n");}}else{this.textBox_log.AppendText("链接失败,或者没有数据");this.textBox_log.AppendText("\r\n");}}}
7、上传功能实现
选择上传的文件按钮点击事件
private void button_select_upload_file_Click(object sender, EventArgs e){OpenFileDialog fileDialog = new OpenFileDialog();fileDialog.Multiselect = true;fileDialog.Title = "请选择文件";if (fileDialog.ShowDialog() == DialogResult.OK){String localFilePath = fileDialog.FileName;//返回文件的完整路径 this.textBox_upload_path.Text = localFilePath;}}
上传文件按钮点击事件
private void button_upload_Click(object sender, EventArgs e){String uploadPath = this.textBox_upload_path.Text;if (String.IsNullOrEmpty(uploadPath)){MessageBox.Show("上传文件路径为空");}else if (!File.Exists(uploadPath)){MessageBox.Show("文件路径不存在");}else {string filename = Path.GetFileName(uploadPath);ftpHelper.UpLoad(uploadPath, out isOk, filename);if (isOk){ MessageBox.Show("上传文件成功");}else{MessageBox.Show("上传文件失败");}}}
上传文件效果
8、扫描文件并实现单次上传和删除文件
选择扫描文件路径按钮点击事件
private void select_scan_path_Click(object sender, EventArgs e){FolderBrowserDialog path = new FolderBrowserDialog();path.ShowDialog();this.textBox_selected_scan_path.Text = path.SelectedPath;}
扫描文件按钮点击事件
private void button_scan_file_Click(object sender, EventArgs e){scanedFileList.Clear();string scanDirectoryPath = this.textBox_selected_scan_path.Text;if (String.IsNullOrEmpty(scanDirectoryPath)){MessageBox.Show("扫描文件路径不能为空");}else{//指定的文件夹目录DirectoryInfo dir = new DirectoryInfo(scanDirectoryPath);if (dir.Exists == false){MessageBox.Show("路径不存在!请重新输入");}else{this.textBox_scan_file_list.Clear();//检索表示当前目录的文件和子目录FileSystemInfo[] fsinfos = dir.GetFiles();if (fsinfos.Length == 0){this.textBox_scan_file_list.AppendText("未扫描到文件");this.textBox_scan_file_list.AppendText("\r\n");}else {//遍历检索的文件和子目录foreach (FileSystemInfo fsinfo in fsinfos){scanedFileList.Add(fsinfo.FullName);this.textBox_scan_file_list.AppendText(fsinfo.FullName);this.textBox_scan_file_list.AppendText("\r\n");}}}}}
单次上传扫描的所有文件按钮点击事件
private void button_upload_scaned_file_Click(object sender, EventArgs e){if (scanedFileList == null || scanedFileList.Count == 0){MessageBox.Show("没有扫描到文件");}else {//this.textBox_log.Clear(); for (int index = 0;index<scanedFileList.Count;index++) {//执行上传操作String uploadPath = scanedFileList[index];if (!File.Exists(uploadPath)){this.textBox_log.AppendText(uploadPath + "路径不存在");this.textBox_log.AppendText("\r\n");}else{string filename = Path.GetFileName(uploadPath);ftpHelper.UpLoad(uploadPath, out isOk, filename);if (isOk){this.textBox_log.AppendText(scanedFileList[index] + "上传成功");this.textBox_log.AppendText("\r\n");if (File.Exists(uploadPath)){File.Delete(uploadPath);this.textBox_log.AppendText(scanedFileList[index] + "删除成功");this.textBox_log.AppendText("\r\n");}else{this.textBox_log.AppendText(scanedFileList[index] + "删除失败");this.textBox_log.AppendText("\r\n");}}else{this.textBox_log.AppendText(scanedFileList[index] + "上传失败");this.textBox_log.AppendText("\r\n");}}}}}
实现效果
9、定时扫描实现
声明一个全局定时器变量
//定时器System.Windows.Forms.Timer _timer = new System.Windows.Forms.Timer();
定时器启动按钮点击事件
private void button_timer_start_Click(object sender, EventArgs e){decimal interval = this.numericUpDown_interval.Value * 1000;_timer.Interval = (int)interval;_timer.Tick += _timer_Tick;_timer.Start();}
定时器执行的具体事件实现
private void _timer_Tick(object sender, EventArgs e){scanedFileList.Clear();string scanDirectoryPath = this.textBox_selected_scan_path.Text;if (String.IsNullOrEmpty(scanDirectoryPath)){MessageBox.Show("扫描文件路径不能为空");}else{//指定的文件夹目录DirectoryInfo dir = new DirectoryInfo(scanDirectoryPath);if (dir.Exists == false){MessageBox.Show("路径不存在!请重新输入");}else{this.textBox_scan_file_list.Clear();//检索表示当前目录的文件和子目录FileSystemInfo[] fsinfos = dir.GetFiles();if (fsinfos.Length == 0){this.textBox_scan_file_list.AppendText(DateTime.Now.ToString()+"未扫描到文件");this.textBox_scan_file_list.AppendText("\r\n");}else{//遍历检索的文件和子目录foreach (FileSystemInfo fsinfo in fsinfos){scanedFileList.Add(fsinfo.FullName);this.textBox_scan_file_list.AppendText(fsinfo.FullName);this.textBox_scan_file_list.AppendText("\r\n");}}}}//执行删除操作if (scanedFileList == null || scanedFileList.Count == 0){this.textBox_log.AppendText(DateTime.Now.ToString()+"没有扫描到文件");this.textBox_log.AppendText("\r\n");}else{//this.textBox_log.Clear(); for (int index = 0; index < scanedFileList.Count; index++){//执行上传操作String uploadPath = scanedFileList[index];if (!File.Exists(uploadPath)){this.textBox_log.AppendText(DateTime.Now.ToString()+uploadPath + "路径不存在");this.textBox_log.AppendText("\r\n");}else{string filename = Path.GetFileName(uploadPath);ftpHelper.UpLoad(uploadPath, out isOk, filename);if (isOk){this.textBox_log.AppendText(DateTime.Now.ToString()+scanedFileList[index] + "上传成功");this.textBox_log.AppendText("\r\n");if (File.Exists(uploadPath)){File.Delete(uploadPath);this.textBox_log.AppendText(DateTime.Now.ToString()+scanedFileList[index] + "删除成功");this.textBox_log.AppendText("\r\n");}else{this.textBox_log.AppendText(DateTime.Now.ToString()+scanedFileList[index] + "删除失败");this.textBox_log.AppendText("\r\n");}}else{this.textBox_log.AppendText(DateTime.Now.ToString()+scanedFileList[index] + "上传失败");this.textBox_log.AppendText("\r\n");}}}}}
定时器停止按钮点击事件
private void button_timer_stop_Click(object sender, EventArgs e){DialogResult AF = MessageBox.Show("您确定停止计时器吗?", "确认框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);if (AF == DialogResult.OK){_timer.Stop();}else{//用户点击取消或者关闭对话框后执行的代码}}
10、完整示例代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace UploadFtpServerSchedule
{public partial class Form1 : Form{private FtpHelper ftpHelper;//是否建立连接bool isOk = false;bool isRight = false;string ipAddr = String.Empty;string port = String.Empty;string userName = String.Empty;string password = String.Empty;//存储扫描的所有文件路径List<String> scanedFileList = new List<string>();//定时器System.Windows.Forms.Timer _timer = new System.Windows.Forms.Timer();public Form1(){InitializeComponent();}//选择扫描文件路径private void select_scan_path_Click(object sender, EventArgs e){FolderBrowserDialog path = new FolderBrowserDialog();path.ShowDialog();this.textBox_selected_scan_path.Text = path.SelectedPath;}//ftp建立连接private void button_connnect_ftpserver_Click(object sender, EventArgs e){try{checkNull();if (isRight){ftpHelper = new FtpHelper(ipAddr, port, userName, password);string[] arrAccept = ftpHelper.ListDirectory(out isOk);//调用Ftp目录显示功能if (isOk){MessageBox.Show("登录成功");}}}catch (Exception ex){MessageBox.Show("登录失败:ex="+ex.Message);}}private void checkNull(){isRight = false;//非空校验ipAddr = this.textBox_addr.Text.Trim();port = this.textBox_port.Text.Trim();userName = this.textBox_name.Text.Trim();password = this.textBox_pass.Text.Trim();if (String.IsNullOrEmpty(ipAddr)){MessageBox.Show("地址不能为空");}else if (String.IsNullOrEmpty(port)){MessageBox.Show("端口不能为空");}else if (String.IsNullOrEmpty(userName)){MessageBox.Show("用户名不能为空");}else if (String.IsNullOrEmpty(password)){MessageBox.Show("密码不能为空");}else {isRight = true;}}//列出所有文件private void button_listDirectory_Click(object sender, EventArgs e){checkNull();if (isRight){ftpHelper = new FtpHelper(ipAddr, port, userName, password);string[] arrAccept = ftpHelper.ListDirectory(out isOk);//调用Ftp目录显示功能if (isOk){this.textBox_log.Clear();foreach (string accept in arrAccept){string name = accept.Substring(39);this.textBox_log.AppendText(name);this.textBox_log.AppendText("\r\n");}}else{this.textBox_log.AppendText("链接失败,或者没有数据");this.textBox_log.AppendText("\r\n");}}}//选择要上传的文件private void button_select_upload_file_Click(object sender, EventArgs e){OpenFileDialog fileDialog = new OpenFileDialog();fileDialog.Multiselect = true;fileDialog.Title = "请选择文件";if (fileDialog.ShowDialog() == DialogResult.OK){String localFilePath = fileDialog.FileName;//返回文件的完整路径 this.textBox_upload_path.Text = localFilePath;}}//上传文件private void button_upload_Click(object sender, EventArgs e){String uploadPath = this.textBox_upload_path.Text;if (String.IsNullOrEmpty(uploadPath)){MessageBox.Show("上传文件路径为空");}else if (!File.Exists(uploadPath)){MessageBox.Show("文件路径不存在");}else {string filename = Path.GetFileName(uploadPath);ftpHelper.UpLoad(uploadPath, out isOk, filename);if (isOk){ MessageBox.Show("上传文件成功");}else{MessageBox.Show("上传文件失败");}}}//扫描文件private void button_scan_file_Click(object sender, EventArgs e){scanedFileList.Clear();string scanDirectoryPath = this.textBox_selected_scan_path.Text;if (String.IsNullOrEmpty(scanDirectoryPath)){MessageBox.Show("扫描文件路径不能为空");}else{//指定的文件夹目录DirectoryInfo dir = new DirectoryInfo(scanDirectoryPath);if (dir.Exists == false){MessageBox.Show("路径不存在!请重新输入");}else{this.textBox_scan_file_list.Clear();//检索表示当前目录的文件和子目录FileSystemInfo[] fsinfos = dir.GetFiles();if (fsinfos.Length == 0){this.textBox_scan_file_list.AppendText("未扫描到文件");this.textBox_scan_file_list.AppendText("\r\n");}else {//遍历检索的文件和子目录foreach (FileSystemInfo fsinfo in fsinfos){scanedFileList.Add(fsinfo.FullName);this.textBox_scan_file_list.AppendText(fsinfo.FullName);this.textBox_scan_file_list.AppendText("\r\n");}}}}}//单次上传扫描的所有文件private void button_upload_scaned_file_Click(object sender, EventArgs e){if (scanedFileList == null || scanedFileList.Count == 0){MessageBox.Show("没有扫描到文件");}else {//this.textBox_log.Clear(); for (int index = 0;index<scanedFileList.Count;index++) {//执行上传操作String uploadPath = scanedFileList[index];if (!File.Exists(uploadPath)){this.textBox_log.AppendText(uploadPath + "路径不存在");this.textBox_log.AppendText("\r\n");}else{string filename = Path.GetFileName(uploadPath);ftpHelper.UpLoad(uploadPath, out isOk, filename);if (isOk){this.textBox_log.AppendText(scanedFileList[index] + "上传成功");this.textBox_log.AppendText("\r\n");if (File.Exists(uploadPath)){File.Delete(uploadPath);this.textBox_log.AppendText(scanedFileList[index] + "删除成功");this.textBox_log.AppendText("\r\n");}else{this.textBox_log.AppendText(scanedFileList[index] + "删除失败");this.textBox_log.AppendText("\r\n");}}else{this.textBox_log.AppendText(scanedFileList[index] + "上传失败");this.textBox_log.AppendText("\r\n");}}}}}private void button_timer_start_Click(object sender, EventArgs e){decimal interval = this.numericUpDown_interval.Value * 1000;_timer.Interval = (int)interval;_timer.Tick += _timer_Tick;_timer.Start();}private void _timer_Tick(object sender, EventArgs e){scanedFileList.Clear();string scanDirectoryPath = this.textBox_selected_scan_path.Text;if (String.IsNullOrEmpty(scanDirectoryPath)){MessageBox.Show("扫描文件路径不能为空");}else{//指定的文件夹目录DirectoryInfo dir = new DirectoryInfo(scanDirectoryPath);if (dir.Exists == false){MessageBox.Show("路径不存在!请重新输入");}else{this.textBox_scan_file_list.Clear();//检索表示当前目录的文件和子目录FileSystemInfo[] fsinfos = dir.GetFiles();if (fsinfos.Length == 0){this.textBox_scan_file_list.AppendText(DateTime.Now.ToString()+"未扫描到文件");this.textBox_scan_file_list.AppendText("\r\n");}else{//遍历检索的文件和子目录foreach (FileSystemInfo fsinfo in fsinfos){scanedFileList.Add(fsinfo.FullName);this.textBox_scan_file_list.AppendText(fsinfo.FullName);this.textBox_scan_file_list.AppendText("\r\n");}}}}//执行删除操作if (scanedFileList == null || scanedFileList.Count == 0){this.textBox_log.AppendText(DateTime.Now.ToString()+"没有扫描到文件");this.textBox_log.AppendText("\r\n");}else{//this.textBox_log.Clear(); for (int index = 0; index < scanedFileList.Count; index++){//执行上传操作String uploadPath = scanedFileList[index];if (!File.Exists(uploadPath)){this.textBox_log.AppendText(DateTime.Now.ToString()+uploadPath + "路径不存在");this.textBox_log.AppendText("\r\n");}else{string filename = Path.GetFileName(uploadPath);ftpHelper.UpLoad(uploadPath, out isOk, filename);if (isOk){this.textBox_log.AppendText(DateTime.Now.ToString()+scanedFileList[index] + "上传成功");this.textBox_log.AppendText("\r\n");if (File.Exists(uploadPath)){File.Delete(uploadPath);this.textBox_log.AppendText(DateTime.Now.ToString()+scanedFileList[index] + "删除成功");this.textBox_log.AppendText("\r\n");}else{this.textBox_log.AppendText(DateTime.Now.ToString()+scanedFileList[index] + "删除失败");this.textBox_log.AppendText("\r\n");}}else{this.textBox_log.AppendText(DateTime.Now.ToString()+scanedFileList[index] + "上传失败");this.textBox_log.AppendText("\r\n");}}}}}private void button_timer_stop_Click(object sender, EventArgs e){DialogResult AF = MessageBox.Show("您确定停止计时器吗?", "确认框", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);if (AF == DialogResult.OK){_timer.Stop();}else{//用户点击取消或者关闭对话框后执行的代码}}}
}
Winform中实现FTP客户端并定时扫描指定路径下文件上传到FTP服务端然后删除文件相关推荐
- win2008文件上传服务器,win2008文件上传到ftp服务器
win2008文件上传到ftp服务器 内容精选 换一换 安装传输工具在本地主机和Windows云服务器上分别安装数据传输工具,将文件上传到云服务器.例如QQ.exe.在本地主机和Windows云服务器 ...
- 将文件上传至ftp服务器,FTP文件上传工具类,将文件上传至服务器指定目录
将文件上传至ftp服务器,传入File对象,将文件上传至ftp服务器 需要配置修改的点: 1. 服务器ip端口(服务器ip 端口22/21). 2. 服务器账号密码(服务器登录用户名密码). 3. 上 ...
- java ftp上传文件 linux_Java实现把文件上传至ftp服务器
用Java实现ftp文件上传.我使用的是commons-net-1.4.1.zip.其中包含了众多的java网络编程的工具包. 1 把commons-net-1.4.1.jar包加载到项目工程中去. ...
- vb发送到文件服务器,VB实现文件上传到FTP服务器
VB实现文件上传到FTP服务器 ftp.txt文件内容为: open 211.118.1.70 dongping sh12345 put ip.jpg bye VB内容为: Private Sub C ...
- Java将文件上传到ftp服务器
Java将文件上传到ftp服务器 首先简单介绍一下什么是FTP,以及如何在自己的电脑上搭建一个ftp服务器: -- FTP是文件传输协议(FTP)是一种客户端/服务器协议,用于将文件传输到主机或与主机 ...
- Win10搭建FTP服务器+java代码实现文件上传至FTP服务器
Win10搭建ftp服务器 打开控制面板 -> 程序和功能,点击启用或关闭Windows功能,勾选红色方框内的选项 控制面板 -> 管理工具,如下打开IIS管理器 先在本地磁盘中创建一个目 ...
- java上传ftp数据丢失_Java:将文件上传到FTP问题(数据包丢失) - java
我正在尝试将文件从Java应用程序传输到FTP服务器 该程序可以正常工作,文件已传输,但是当我在FTO文件夹中打开文件时,文件已损坏,我认为在文件传输过程中数据包丢失了.为什么?我该如何解决? 另一个 ...
- 文件上传到ftp服务器大小变小,ftp服务器文件上传大小设置
ftp服务器文件上传大小设置 内容精选 换一换 文件选择上传控件,用于上传文件. Windows场景中,当把源端服务器迁移到华为云后,目的端服务器C盘的已用空间比对应源端服务器C盘的已用空间大至少1G ...
- 文件上传到ftp服务工具类
直接引用此java工具类就好 3 import java.io.File; 4 import java.io.FileInputStream; 5 import java.io.FileNotFoun ...
最新文章
- VS.net2008正式版发布了
- 阿里云引领云原生进化,智能、互联、可信三位一体
- lhgselect 联动选择下拉菜单 v1.0.0 (2011-06-13)
- python中itsdangerous模块
- JS - this,call,apply
- python 并发编程 多线程 守护线程
- 【FreeRTOS】FreeRTOS学习笔记(3)— FreeRTOS任务与协程
- Calendar自然周
- python pandas 分割DataFrame中的字符串及元组
- 打印店打印黑白A4纸收费1元一张贵吗?
- catv系统主要有哪三部分组成_数控系统由哪几部分组成
- 集货运输优化:数学建模步骤,Python实现蚁群算法(解决最短路径问题), 蚁群算法解决旅行商问题(最优路径问题),节约里程算法
- 什么蓝牙耳机适合打游戏?打游戏不延迟的蓝牙耳机
- git使用学习四、git add忽略指定文件夹与文件
- 华为nova8pro和nova9pro的区别
- 数据挖掘公开课推荐(含下载链接)
- 斗地主排序和音乐系统管理
- 光照贴图UV Lightmapping UVs
- WordPress视频主题Qinmei 2.0
- blur和change事件区别
热门文章
- Python 计算机视觉(十三)—— 图像的傅里叶变换
- dom定义了访问html文档对象的,HTML DOM (文档对象模型)
- asp 转换html代码,asp下实现对HTML代码进行转换的函数
- python urllib3离线安装_全球Python库下载前10名
- zookeeper在window下的搭建
- 如何将单选题多选题分开_别再说不会分析多选题了!这6种方法解决你的烦恼!...
- 苹果手机怎么清理听筒灰尘_安卓 | 让手机自动清理听筒扬声器灰尘,你试过了吗?...
- 电脑开机一会就蓝屏怎么回事_客户电脑老是出现问题,三天来找三次麻烦!拆机后“真凶”大白!...
- java数组编译后_Java中数组和集合的foreach操作编译后究竟是啥
- 服务器硬件及RAID配置