FTP_transfer/download.cpp
2024-09-12 18:40:56 +08:00

38 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* 此程序演示采用开发框架的cftpclient类下载文件。
*/
#include "_ftp.h"
using namespace eviwbh;
int main(int argc,char *argv[])
{
cftpclient ftp;
// 登录远程ftp服务器请改为你自己服务器的ip地址。
if (ftp.login("192.168.150.128:21","eviwbh","password") == false)
{
printf("ftp.login(192.168.150.128:21,eviwbh/password) failed.\n"); return -1;
}
// 把服务器上的/home/eviwbh/tmp/demo51.cpp下载到本地存为/tmp/test/demo51.cpp。
// 如果本地的/tmp/test目录不存在就创建它。
if (ftp.get("/home/eviwbh/tmp/demo51.cpp","/tmp/test/demo51.cpp")==false)
{
printf("ftp.get() failed.\n"); return -1;
}
printf("get /home/eviwbh/tmp/demo51.cpp ok.\n");
/*
// 删除服务上的/home/eviwbh/tmp/demo51.cpp文件。
if (ftp.ftpdelete("/home/eviwbh/tmp/demo51.cpp")==false) { printf("ftp.ftpdelete() failed.\n"); return -1; }
printf("delete /home/eviwbh/tmp/demo51.cpp ok.\n");
// 删除服务器上的/home/eviwbh/tmp目录如果目录非空删除将失败。
if (ftp.rmdir("/home/eviwbh/tmp")==false) { printf("ftp.rmdir() failed.\n"); return -1; }
*/
}