Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone!
I used the CFtpConnection::GetFile to download the file from server,
but I found a odd question.
The downloaded file can't update.
It means the file I downloaded wouldn't be latest if the file of server has updated.

main code:
C#
CInternetSession *InternetSession;
CFtpConnection *m_pFtpConnection;
void CFTP_testDlg::OnBnClickedButtonConnect()
{
   CString sServerIP, sUser, sPassword;

   sServerIP=_T("192.168.7.123");
   sUser=_T("kobe2");
   sPassword=_T("kobe2");

   InternetSession = new CInternetSession(_T("My Ftp Session"));

   m_pFtpConnection = 
     InternetSession->GetFtpConnection(sServerIP,sUser,sPassword,21,true); 
   //Passive FTP
}
void CFTP_testDlg::OnBnClickedButtonGetFile()
{
    bool bGetFile=false;
    bGetFile=m_pFtpConnection-   >GetFile(_T("RemoteSetting//Server.ini"),_T(".//Server.ini"),false);

    if(bGetFile)
        MessageBox(_T("Download Succeed!"),_T("Info"), MB_OK | MB_ICONINFORMATION );
    else
        MessageBox(_T("Download Fail!"),_T("Info"), MB_OK | MB_ICONINFORMATION );
}

I'm so appreciated if somebody could give me a suggestion.

Thanks a lot!!
Posted
Updated 4-Nov-14 16:12pm
v2

not exactely sure what you mean by

Quote:
The downloaded file can't update.
It means the file I downloaded wouldn't be latest if the file of server has updated.


can you please try and re-phrase what the issue is .. I see

a) you can download a file
b) you cant update the file on your local machine

is that it ?
 
Share this answer
 
Comments
Member 10307999 5-Nov-14 0:56am    
Thanks for your reply!
Sorry! I don't specify exactly.
In local machine, I can download the correct file from the server first time.
If the file changes the content, I CAN'T update the correct file again in local machine.
in local machine, it will produce the oldest file which is I first download, if I press the GetFile button afterwards.
Thanks!
I found the question by myself.
original:
bGetFile=m_pFtpConnection->GetFile(_T("Server.ini"),_T(".//Download.ini"),false);
change to:
bGetFile=m_pFtpConnection->GetFile(_T("RemoteSetting//Server.ini")
,_T(".//Server.ini")
,false
,FILE_ATTRIBUTE_NORMAL
,FTP_TRANSFER_TYPE_BINARY|INTERNET_FLAG_RELOAD
);
It can download the latest file from server:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900