FTP傻瓜调用类
举例(里面无关用到的变量和方法请自行替换为自己的业务代码):
FtpServer ftp = new FtpServer
{
FtpHost = FtpHostIP,
FtpPort = Utility.ToInt(this.FtpPort, 21),
FtpUser = FtpUser,
FtpPassword = FtpPassword
};
ftp.Connect();
ftp.FtpRootPath = FtpUpdatepackageRootPath;
ftp.DirRootChange("/");
try
{
ftp.Get("Deploy.xml", this.TempPath);
}
catch
{
MsgBox.Show(string.Format("更新FTP目录“{0}”无法正常访问,请联系信息管理员解决此问题。", FtpUpdatepackageRootPath));
}
var upkg = UpdatePackageXmlUtil.LoadFromFile(AppPath.MakeAbstractPath(this.TempPath, "Deploy.xml"));
_updatePackage = upkg;
upkg.RootPath = FtpUpdatepackageRootPath;
var rp = new ReportParam { ProcessReportType = "0" };
rp.DicParam.Add("文件数量", upkg.GetAllUpdateFileCount());
this.backgroundWorker.ReportProgress(0, rp);
foreach (var ui in upkg.UpdateItems)
{
DownUpdateItems(ftp, ui, this.TempPath, this.TargetPath);
}
ftp.DisConnect();
你这到底是FTP 服务端还是客户端? 下载研究学习,感谢您 的付出。 正好有帮助,谢了
页:
[1]