c#如何通过ftp上传文件_定时上传文件到ftp,如何使用工具定时上传文件到ftp
IIS7服務(wù)器管理工具-FTP客戶端
作為FTP客戶端,它支持批量管理FTP站點(diǎn)
具體功能:
1.自動重連;2.自動重傳;3.定時任務(wù)(定時上傳、定時下載);4.自定義傳輸模式、線程、編碼;5.刪除到回收站;6.大量文件快速加載、邊加載邊傳輸;7.批量連接一鍵關(guān)閉
官網(wǎng)傳送門:fwqglgj.iis7.net/cp/ftp/?tscd-zc
配置方式:
一、選擇ftp窗口,點(diǎn)擊FTP設(shè)置
二、進(jìn)入“FTP設(shè)置”—“任務(wù)設(shè)置”后,我們先添加任務(wù)
1、新建任務(wù)(一個任務(wù)只能選擇一種時間周期)
1-1:如何設(shè)置 天級定時上傳或下載任務(wù)
1-2:如何設(shè)置 周級定時上傳或下載任務(wù)
1-3:如何設(shè)置 月級定時上傳或下載任務(wù)
注意點(diǎn):備份類型的選擇
追加:新文件。
修改:新文件,或者修改內(nèi)容后的文件。
覆蓋:不對比文件,直接覆蓋原文件。(不推薦)
2、接下來選擇FTP(以下示例定時上傳操作教程)
2-1:點(diǎn)擊“選擇FTP”
2-2:進(jìn)入FTP綁定界面
2-3:成功綁定一臺ftp站點(diǎn)
2-4:ftp綁定信息及任務(wù)執(zhí)行結(jié)果會在設(shè)置界面下方顯示
三、提示任務(wù)上傳成功之后,我們?nèi)?yīng)ftp服務(wù)器查看任務(wù)是否上傳完成
經(jīng)查看,文件已成功上傳!
注意:本文以上傳為例,如果需要下載只要將傳輸方向改為“下載”即可!
java配置方式如下:
import com.enterprisedt.net.ftp.*;
public class FtpClient {
static FTPClient ftpClient;
public FtpClient(){};
String remoteAddress="192.168.168.33",userName="cattsoft",password="cattsoft";
public void DownLoad(){
try{
FTPClient client = new FTPClient();
client.setRemoteHost(remoteAddress);
client.connect();
client.login(userName,password);
client.setType(FTPTransferType.BINARY);
client.get("E:uploadindex.jsp","/home/cattsoft/jakarta-tomcat-5.0.28/webapps/vip/dkf/index2.jsp");
client.quit();
System.out.println("下載成功...");
}catch(Exception e){
e.printStackTrace();
System.out.println("下載失敗...");
}
}
public static void main(String[] args){
FtpClient fc = new FtpClient();
fc.DownLoad();
}
}
java下配置連接FTP:
public void putTxtToFTP() {
System.out.println("開始執(zhí)行定時器任務(wù):維系一鍵訂單量!");
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, -1); //得到前一天
Date date = calendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
String yesterday = df.format(date);
StringBuffer yjtjOrderTxt = new StringBuffer();
yjtjOrderTxt.append("yjtywx_").append(yesterday).append(".txt");
List yjtjOrderList = activeDataService.wxGetYjtjOrder();
//FtpUtil ftpUtil = new FtpUtil("hexin","hx105155","134.64.105.155", "/yjtydd"); //測試庫FTP
FtpUtil ftpUtil = new FtpUtil("ahftp","ahdx@#$_123dic","192.168.0.28", "/yjtydd");
PrintWriter printWriter = null;
File highFeeFile = new File(Contants.FILE_PATH_BAK + yjtjOrderTxt);//Contants.FILE_PATH_BAK = "/opt/wss/domains/tmp/"
// File highFeeFile = new File("D:/" + highFeeTxt);
// File gjmyFile = new File("D:/" + gjmyTxt);
//File highFeeFile = new File("D:/" + yjtjOrderTxt);
try {
printWriter = new PrintWriter(new FileWriter(highFeeFile, true));
for (int i = 0; i < yjtjOrderList.size(); i++){
printWriter.println(yjtjOrderList.get(i).toString().trim());
}
} catch (IOException e) {
System.out.println("主動服務(wù) 高額數(shù)據(jù)報表任務(wù)異常!");
}finally{
printWriter.close();
}
if(highFeeFile.exists()){
System.out.println("主動服務(wù)定時器任務(wù) 高額數(shù)據(jù) 上傳成功"+yjtjOrderTxt.toString());
ftpUtil.uploadFile(highFeeFile, yjtjOrderTxt.toString());
}else{
System.out.println("主動服務(wù)定時器任務(wù) 高額數(shù)據(jù) 上傳失敗"+yjtjOrderTxt.toString());
}
System.out.println("服務(wù)器批量查排名-查詢結(jié)果");
}
public ActiveDataService getActiveDataService() {
return activeDataService;
}
public void setActiveDataService(ActiveDataService activeDataService) {
this.activeDataService = activeDataService;
}?
總結(jié)
以上是生活随笔為你收集整理的c#如何通过ftp上传文件_定时上传文件到ftp,如何使用工具定时上传文件到ftp的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c语言位运算_C语言自增减、逻辑运算、位
- 下一篇: iphone各机型参数对比_我们对比新旧