ftp 下载时防止从缓存中获取文件
//http://baike.baidu.com/link?url=QucJiA_Fg_-rJI9D4G4Z4687HG4CfhtmBUd5TlXrcWCeIEXCZxIh0TD7ng1wROAzAuGD8qncM65XK4BZ1K1uqq
int CFTP_MFC_TESTDlg::FTP_DownLoadFile(char *FtpIp, char *User, char *Password, char *FtpPath, char *FileName, char *DownLoadPath)
{
HINTERNET hInternet;
HINTERNET hConnect;
BOOL bRes;
hInternet = InternetOpen("A3GS Sample",
INTERNET_OPEN_TYPE_DIRECT,
NULL,
NULL,
INTERNET_FLAG_NO_CACHE_WRITE);
if ( NULL == hInternet )
{
return -1;
}
hConnect = InternetConnect(hInternet,
FtpIp,
INTERNET_DEFAULT_FTP_PORT,
User,
Password,
INTERNET_SERVICE_FTP,
INTERNET_FLAG_EXISTING_CONNECT || INTERNET_FLAG_PASSIVE,
0 );
if ( NULL == hInternet )
{
InternetCloseHandle(hInternet);
return -2;
}
//设置ftp的文件所在的文件夹,这样才能正常下载
FtpSetCurrentDirectory(hConnect, FtpPath);
bRes = FtpGetFile(hConnect,FileName,DownLoadPath,FALSE,FILE_ATTRIBUTE_ARCHIVE,FTP_TRANSFER_TYPE_UNKNOWN | INTERNET_FLAG_RELOAD,0);//INTERNET_FLAG_RELOAD 强制重读数据
InternetCloseHandle(hConnect);
InternetCloseHandle(hInternet);
if( bRes )
return 0;
else
return -3;
}
{
HINTERNET hInternet;
HINTERNET hConnect;
BOOL bRes;
hInternet = InternetOpen("A3GS Sample",
INTERNET_OPEN_TYPE_DIRECT,
NULL,
NULL,
INTERNET_FLAG_NO_CACHE_WRITE);
if ( NULL == hInternet )
{
return -1;
}
hConnect = InternetConnect(hInternet,
FtpIp,
INTERNET_DEFAULT_FTP_PORT,
User,
Password,
INTERNET_SERVICE_FTP,
INTERNET_FLAG_EXISTING_CONNECT || INTERNET_FLAG_PASSIVE,
0 );
if ( NULL == hInternet )
{
InternetCloseHandle(hInternet);
return -2;
}
//设置ftp的文件所在的文件夹,这样才能正常下载
FtpSetCurrentDirectory(hConnect, FtpPath);
bRes = FtpGetFile(hConnect,FileName,DownLoadPath,FALSE,FILE_ATTRIBUTE_ARCHIVE,FTP_TRANSFER_TYPE_UNKNOWN | INTERNET_FLAG_RELOAD,0);//INTERNET_FLAG_RELOAD 强制重读数据
InternetCloseHandle(hConnect);
InternetCloseHandle(hInternet);
if( bRes )
return 0;
else
return -3;
}