越小,功能简单实现全好...谢谢了.

解决方案 »

  1.   

    http://www.vckbase.com/document/viewdoc/?id=1387
      

  2.   

    CString ServerXu="192.168.8.1";
    CString message="网络服务器 "+ServerXu;
    CFtpConnection* connection=NULL;
        CInternetSession session;
    BOOL win;
    try
    {
    connection=session.GetFtpConnection(ServerXu,username,
    password,iPort,FALSE);
    }
    catch(CInternetException* pEx)
    {
    connection=NULL;
    pEx->Delete();
    }
    if(!connection)
    {
    win=FALSE; 
    message+="连接中断!请稍候再试。\r\n";
    AfxMessageBox(message);
    return;
    }
    else
    win=TRUE;
      

  3.   

    谢谢cpio,青蛙.可以下文件就行了..
      

  4.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_ftptree.asp
      

  5.   

    /*
    功能实现FTP封装作者:渊海
    作成日期:2005-09-26*/
    #include "FtpDll.h"
    #include "FtpBase.H"
    #include <windows.h>FTPEXPORT bool SetAccessRight(char *userName,char *userPass)
    {
    strcpy(FtpBase.ServerInfo.strPass,userPass);
    strcpy(FtpBase.ServerInfo.strUser,userName); if( !strcmp(FtpBase.ServerInfo.strPass,"") || !strcmp(FtpBase.ServerInfo.strUser,""))
    return 0; return 1;
    }FTPEXPORT bool OpenConnection(char * server)
    {
    if(!strcmp(server,""))
    return 0; strcpy(FtpBase.ServerInfo.strServerName,server); try 
    {
    FtpBase.InternetSession = InternetOpen(
    "NEC FTP SERVER TO CLIENT",
    INTERNET_OPEN_TYPE_DIRECT,
    NULL,
    NULL,
    0);
    FtpBase.FtpConnection = InternetConnect(
    FtpBase.InternetSession,
    FtpBase.ServerInfo.strServerName ,
    INTERNET_DEFAULT_FTP_PORT,
    FtpBase.ServerInfo.strUser ,
    FtpBase.ServerInfo.strPass ,
    INTERNET_SERVICE_FTP,
    0,
    0); }
    catch (CInternetException* pEx) 
    {
    pEx->Delete();
    return 0;
    }
    return 1;
    }FTPEXPORT bool CloseConnection()
    {
    if(FtpBase.FtpConnection == NULL)
    return 0; try
    {
    InternetCloseHandle(FtpBase.InternetSession); 
    InternetCloseHandle(FtpBase.FtpConnection);
    }
    catch(...)
    {
    return 0;
    } return 1;
    }FTPEXPORT bool PutFile(char * localFile, char * remoteFile)
    {
    BOOL bGotFile = FtpPutFile(
    FtpBase.FtpConnection,
    localFile,
    remoteFile,
    FTP_TRANSFER_TYPE_BINARY,
    NULL);
    return bGotFile ? 1 : 0 ;
    }FTPEXPORT bool GetFile(char * remoteFile,char * localFile)
    {
    BOOL bGotFile = FtpGetFile(
    FtpBase.FtpConnection,
    remoteFile,
    localFile,
    FALSE,
    FILE_ATTRIBUTE_NORMAL,
    FTP_TRANSFER_TYPE_BINARY,
    NULL);
    return bGotFile ? 1 : 0 ;
    }FTPEXPORT bool RemoveFile(char * sFileName)
    {
    BOOL bGotFile = FtpDeleteFile(FtpBase.FtpConnection,sFileName);
    return bGotFile ? 1 : 0 ;
    }
    FTPEXPORT bool GetFTPDirectory(char * strDir)
    {
    DWORD dirlen=0; BOOL bGotFile = FtpGetCurrentDirectory(
    FtpBase.FtpConnection,
    strDir,
    &dirlen); return bGotFile ? 1 : 0 ;
    }FTPEXPORT bool SetFTPDirectory(char * strDir)
    {
        BOOL bGotFile = FtpSetCurrentDirectory(
    FtpBase.FtpConnection,
    strDir); return bGotFile ? 1 : 0 ;
    }
    FTPEXPORT HINTERNET OpenFile(char * strFile,int mode)
    {
    try
    {
    if(mode)
    FtpBase.FileConnt=FtpOpenFile(
    FtpBase.FtpConnection,
    strFile,
    GENERIC_WRITE,
    FTP_TRANSFER_TYPE_BINARY,
    0);
    else
    FtpBase.FileConnt=FtpOpenFile(
    FtpBase.FtpConnection,
    strFile,
    GENERIC_READ,
    FTP_TRANSFER_TYPE_BINARY,
    0);
    }
    catch(...)
    {
    return NULL;
    } return FtpBase.FileConnt;}
    FTPEXPORT bool WriteFile(HINTERNET hFile,char * buf)
    {
    DWORD buflen=0; BOOL bGotFile = InternetWriteFile(hFile,
    buf,
    strlen(buf),
    &buflen); return bGotFile ? 1 : 0 ;
    }
    FTPEXPORT bool ReadFile(HINTERNET hFile,char * buf)
    {
    DWORD buflen=0; BOOL bGotFile = InternetReadFile(hFile,
    buf,
    strlen(buf),
    &buflen); return bGotFile ? 1 : 0 ;
    }
    FTPEXPORT bool CloseFile(HINTERNET hFile)
    {
    try
    {
    InternetCloseHandle(hFile); 
    }
    catch(...)
    {
    return 0;
    } return 1;
    }