private void FtpTrans(SysBackupServerEntity model, string backupPath, string virtualPath, string strPath, string chkDrop) { Task.Run(() => { if (model != null) { FTPHelper ftp = new FTPHelper(model.F_FtpServerIp, "", model.F_FtpUserId, model.F_FtpPassword); if (!ftp.IsDirectoryExist(backupPath)) { ftp.CreateDirectory(backupPath); } ftp = new FTPHelper(model.F_FtpServerIp, backupPath, model.F_FtpUserId, model.F_FtpPassword); ZipFloClass Zc = new ZipFloClass(); //将文件夹进行GZip压缩 Zc.ZipFile(Server.MapPath(virtualPath), strPath); //生成压缩包 if (chkDrop == "true") { //遍历删除当前目录文件 List <FileStruct> ListFiles = ftp.ListFiles(); if (ListFiles.Count > 0) { foreach (var item in ListFiles) { ftp.DeleteFile(item.Name); } } } ftp.Upload(strPath); //通过ftp传到服务器 FileHelper.DeleteFile(strPath); //删除临时压缩包 } }); }