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"));
}
&

这篇博客记录了作者在C++中实现FTP上传的过程,首先尝试使用MFC的afxinet.h库,但由于工程限制转向了使用WinINet API。提供了相关头文件引用及MSDN的API参考链接。
3344

被折叠的 条评论
为什么被折叠?



