Click to See Complete Forum and Search --> : Need help on CFTPConnection....Urgent


Niranjan
July 20th, 1999, 11:04 AM
Hi Folks,
I am new to VC++ ...
I am using CFTPConnection, CInternetSession for doing the ftp. How can I get a file from remote server to a particular directory on local machine ?
There are functions to change the remote directory but nothing to change local directory ...Are there any functions like SetDirectory for changing local path !
I tried
Cstring LocalFile = "C:\\windows\\test1.dat"
RetVal = FTPConnection->GetFile(LocalFile,FileName,FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_ASCII,1);

Doesn't work !!!

I need urgent help !!!

Leila Melloto
July 20th, 1999, 02:20 PM
A sample:
CString strDirRemote="/temp",
strNomeArq = "exemplo.txt",
strDirLocal = "c:/windows/temp";
BOOL bResult = m_FtpConnection->SetCurrentDirectory ( strDirRemote);
if ( bResult )
{
CString strArquivoOrigem, strArquivoDestino;
BOOL bFailIfExists = FALSE;
strArquivoOrigem = strDirRemote;
strArquivoOrigem += "/";
strArquivoOrigem += strNomeArq ;
strArquivoDestino = strDirLocal;
strArquivoDestino += "/";
strArquivoDestino += strNomeArq;
DWORD dwFlagFtpTransferType;
dwFlagFtpTransferType =FTP_TRANSFER_TYPE_ASCII;
dwFlagFtpTransferType |=INTERNET_FLAG_RELOAD;
m_FtpConnection->GetFile ( strArquivoOrigem, strArquivoDestino,bFailIfExists, FILE_ATTRIBUTE_NORMAL, dwFlagFtpTransferType);
}

Hope this helps,

Leila

maheshbeniwal
August 20th, 1999, 04:08 PM
this sample does not work. Any idea ??
Here is my code and it does not work too. Any body help .....

I am connected to ftp b.c iu can set current directory. userID and passwords are correct ..

=========================
CFtpConnection* ftp;
ftp = session.GetFtpConnection( g_strServerName , szUser, szPassword, (INTERNET_PORT) g_nPort);
ftp->SetCurrentDirectory("/kruse") ;

ftp->GetFile("/kruse/abc.txt", "c:/windows/temp/qick.txt", FALSE, FILE_ATTRIBUTE_NORMAL, 1 ) ;

if ( ftp->PutFile("C:/Mahesh.txt", "/Kruse/Mahesh.txt", FTP_TRANSFER_TYPE_ASCII, 1 ) != 0 )
AfxMessageBox("success");

pjprabhu
September 19th, 1999, 03:42 AM
Try changing the statement below from

RetVal = FTPConnection->GetFile(LocalFile,FileName,FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_ASCII,1);




to


RetVal = FTPConnection->GetFile(FileName,LocalFile,FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_ASCII,1);