ps:做个简单的上传FTP处理要用,做个记录。FTP使用vsftpd实现。
part1:
使用afxinet.h提供的来完成,这个是属于MFC的。刚好我需要完成程序还不能使用MFC
头文件:当然是#include <afxinet.h>
简单使用MSDN例程,
CInternetSession sess(_T("My FTP Session"));
CFtpConnection* pConnect = NULL;
try
{
// Request a connection to ftp.microsoft.com. Default
// parameters mean that we'll try with username = ANONYMOUS
// and password set to the machine name @ domain name
pConnect = sess.GetFtpConnection(_T("192.168.1.1","","",21));//这里输入参数是服务器地址+登陆名+密码+端口
pConnect->SetCurrentDirectory(L"test");//传入的文件
CString strLocfile,strRemotefile; //传入FTP文件名 和 源文件信息
int m = pConnect->PutFile(strLocfile,strRemotefile,FTP_TRANSFER_TYPE_BINARY,1);
if (!m)
{
_tprintf_s(_T("UpLoad Failed"));
}
&