社区
数据运维
帖子详情
程序连接ftp 怎么写
运维螺丝钉
2019-02-21 10:59:39
程序连接ftp 怎么写,有哪位有爱心的大神级高手,提供一下思路或现成的代码
...全文
290
2
打赏
收藏
程序连接ftp 怎么写
程序连接ftp 怎么写,有哪位有爱心的大神级高手,提供一下思路或现成的代码
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
运维螺丝钉
2019-03-11
打赏
举报
回复
谢谢了,大神的帮助
rococor
2019-03-08
打赏
举报
回复
一个用C#写的代码,你看是否能用 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Net; using System.Net.FtpClient; using System.Text; using System.Threading.Tasks; using System.IO; namespace FTP_Client { public class FTPConnection { public FTPConnection() { } /// <summary> /// 连接FTP服务器函数 /// </summary> /// <param name="strServer">服务器IP</param> /// <param name="strUser">用户名</param> /// <param name="strPassword">密码</param> public bool FTPIsConnected(string strServer, string strUser, string strPassword) { using (FtpClient ftp = new FtpClient()) { ftp.Host = strServer; ftp.Credentials = new NetworkCredential(strUser, strPassword); ftp.Connect(); return ftp.IsConnected; } } /// <summary> /// FTP下载文件 /// </summary> /// <param name="strServer">服务器IP</param> /// <param name="strUser">用户名</param> /// <param name="strPassword">密码</param> /// <param name="Serverpath">服务器路径,例子:"/Serverpath/"</param> /// <param name="localpath">本地保存路径</param> /// <param name="filetype">所下载的文件类型,例子:".rte"</param> public bool FTPIsdownload(string strServer, string strUser, string strPassword,string Serverpath, string localpath, string filetype) { FtpClient ftp = new FtpClient(); ftp.Host = strServer; ftp.Credentials = new NetworkCredential(strUser, strPassword); ftp.Connect(); string path = Serverpath; string destinationDirectory = localpath; List<string> documentname = new List<string>(); bool DownloadStatus = false; if (Directory.Exists(destinationDirectory)) { #region 从FTP服务器下载文件 foreach (var ftpListItem in ftp.GetListing(path, FtpListOption.Modify | FtpListOption.Size) .Where(ftpListItem => string.Equals(Path.GetExtension(ftpListItem.Name), filetype))) { string destinationPath = string.Format(@"{0}\{1}", destinationDirectory, ftpListItem.Name); using (Stream ftpStream = ftp.OpenRead(ftpListItem.FullName)) using (FileStream fileStream = File.Create(destinationPath, (int)ftpStream.Length)) { var buffer = new byte[200 * 1024]; int count; while ((count = ftpStream.Read(buffer, 0, buffer.Length)) > 0) { fileStream.Write(buffer, 0, count); } } documentname.Add(ftpListItem.Name); } #endregion #region 验证本地是否有该文件 string[] files = Directory.GetFiles(localpath, "*"+filetype); int filenumber = 0; foreach(string strfilename in files) { foreach(string strrecievefile in documentname) { if (strrecievefile == Path.GetFileName(strfilename)) { filenumber++; break; } } } if(filenumber==documentname.Count) { DownloadStatus = true; } #endregion } return DownloadStatus; } } }
亲测可用—SecureCRTandSecureFXv7.3.3x86x64build779正式版-附带注册机
它主要用于Linux操作系统如redhat, ubuntu的客户端文件传输
程序
,您可以选择利用S
FTP
通过加密的SSH2实现安全传输,也可以利用
FTP
进行标准传输。该客户端具有Explorer风格的界面,易于使用,同时提供强大的自动化能力...
java
连接
FTP
服务器
第一,根据
FTP
协议自己
写
出一套
程序
,这是一种思路,当然这是一件很费时又耗成本的一件事。我们是工程师,我们的目的是把需求实现,而不是科研项目。所以得考虑另一种思路,去寻找已经做好的API。好巧,刚好有一个...
Java
连接
ftp
服务器
直接上代码测试,结果第一步就卡住了,卡在了hostname的
连接
上,通过FileZilla
连接
过程初步判断是证书和加密方式的问题,然后就自己建了一个不含ssl证书,明文传输的,默认端口21的
ftp
,
连接
并操作果然完全没问题。...
Java——通过Java代码
连接
ftp
服务器
import org.apache.commons.net.
ftp
.
FTP
Reply; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype....
IE浏览器无法通过
ftp
:\\192.168.xxx.xxx
连接
ftp
服务器
描述:Dos窗口通过
ftp
192.168.xxx.xxx可以
连接
ftp
服务器,但IE浏览器无法通过
ftp
:\\192.168.xxx.xxx
连接
ftp
服务器 方法:
ftp
支持主动和被动两种
连接
模式,默认为主动模式;通过
ftp
:\\ 192.168.xxx.xxx
连接
ftp
...
数据运维
1,092
社区成员
968
社区内容
发帖
与我相关
我的任务
数据运维
云计算服务器、网络、虚拟化相关讨论
复制链接
扫一扫
分享
社区描述
云计算服务器、网络、虚拟化相关讨论
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章