我想实现FTP客户端的以下功能:
1/连接FTP服务器
2/从FTP服务器上GET指定路径下的指定文件到本机指定的文件夹下,一次get一个文件
3/断开FTP服务器连接请各位帮忙看看,有没有代码或是控件什么的,谢谢

解决方案 »

  1.   

    CFtpConnection可以完成你要的功能。 CInternetSession sess(_T("MyProgram/1.0"));
    CFtpConnection* pConnect=NULL; try
    {
    pConnect=sess.GetFtpConnection("202.98.10.206","c51bbs","c51bbs");
    CFtpFileFind finder(pConnect);
    BOOL bWorking=finder.FindFile(_T("*"));
    while(bWorking)
    {
    bWorking =finder.FindNextFile();
    printf("%s\n",(LPCTSTR)finder.GetFileURL());
    }
    }
    catch(CInternetException* pEx)
    {
    TCHAR sz[1024];
    pEx->GetErrorMessage(sz,1024);
    printf("ERROR! %s\n",sz);
    pEx->Delete();
    }
      

  2.   

    网上有很多ftp客户端的源代码
      

  3.   

    上面的代码好像不能get文件啊?
      

  4.   

    在while 里,把print变成 
    pConnect->GetFile(finder.GetFileName(),finder.GetFileName());
      

  5.   

    那finder.GetFileName()应该怎么赋值呢?能不能写整理个完整的代码?谢谢
      

  6.   

    比如在FTP上的是/zx/test.txt这个文件,本机我要下载到d:\log下面
      

  7.   

    1.CFtpConnection初始化对象。
    2.对象.SetCurrentDirectory设置到/zx/目录
    3.GetFile("test.txt","d:\\log\\")
    完成上述流程,我相信你能搞定。