官网:https://pocoproject.org/
#pragma once
#include "Poco/Net/FTPClientSession.h"
#include "Poco/Net/DialogSocket.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/Net/NetException.h"
#include "Poco/Thread.h"
#include "Poco/ActiveMethod.h"
#include "Poco/StreamCopier.h"
#include <sstream>
#include <string>
using Poco::Net::FTPClientSession;
using Poco::Net::SocketAddress;
using Poco::Net::FTPException;
using std::string;
class CFtper
{
public:
CFtper();
~CFtper();
private:
FTPClientSession* m_Connector;
private:
std::string mServerIP;
unsigned int mServerPort;
std::string mUserName;
std::string mUserPassword;
};
#include <string>
using namespace std;
m_Connector = new FTPClientSession();
FTPClientSession session(mServerIP, mServerPort);//创建FTP会话对象
session.login(mUserName, mUserPassword); //登录
//session.setWorkingDirectory("homepage/"); //转到工作目录
bool isConnected = session.isLoggedIn();
if (isConnected)
AfxMessageBox(_T("连接成功"));
else
AfxMessageBox(_T("连接失败"));
isConnected = false;
isConnected = session.isOpen();
if (isConnected)
AfxMessageBox(_T("打开成功"));
else
AfxMessageBox(_T("打开失败"));
std::string str = session.getWorkingDirectory();
CString str2;
str2 = str.c_str();
AfxMessageBox(str2);
//for (int i = 0; i < str.size(); i++)
// str.push_back(str[i]);
//str.push_back('\n');
//CString str;
//str.Format("%s", curDirectory.c_str());
//AfxMessageBox(str);
//CString str2;
std::string result;
session.sendCommand("LIST ",result);
str2 = result.c_str();
AfxMessageBox(str2);
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于