int FromServer ( char * _pCharReadDirServer, char * _pCharWriteDirLocal)
{
if ( pObjFtpConn == 0 )
return 0;
pObjFtpConn->SetCurrentDirectory( _pCharReadDirServer );
CFtpFileFind finder( pObjFtpConn );
BOOL bHaveFile = finder.FindFile();
while ( bHaveFile )
{
bHaveFile = finder.FindNextFile();
CFile objFile;
CString strLocation(_pCharWriteDirLocal);
strLocation.Append( finder.GetFileName() );
if ( !objFile.Open( strLocation, CFile::modeCreate | CFile::modeWrite ) )
return 0;
CInternetFile * pObjInternetFile;
/***************************** 这里出错 **********************************/
// read
try {
pObjInternetFile = pObjFtpConn->OpenFile( finder.GetFileName(), GENERIC_READ );
}
catch ( CInternetException e )
{return 0;}
/**************************************************************************/
char * pCharBuff = new char[1024];
int nBuffLng = pObjInternetFile->Read( pCharBuff, 1024 );
while ( nBuffLng )
{
// write to local file
objFile.Write( pCharBuff, nBuffLng );
nBuffLng = pObjInternetFile->Read( pCharBuff, 1024 );
}
pObjInternetFile->Close();
delete pObjInternetFile;
//delete
pObjFtpConn->Remove( finder.GetFileName() );
objFile.Close();
delete pCharBuff;
}
finder.Close();
return 1;
}
自己用---OpenFile
最新推荐文章于 2017-01-23 23:37:12 发布