CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Location
    Bangalore
    Posts
    78

    FtpGetFile() fails!

    Hi All,

    My call to FtpGetFile fails, return an error code of 12003.

    Any help would be appreciated.

    With Regards,
    A.Ilamparithi.


    HINTERNET hInternetSession;
    HINTERNET hFTPSession;
    HINTERNET hFileConnection;
    BOOL bResult = TRUE;
    hInternetSession = ::InternetOpen(

    "Microsoft Internet Explorer", // agent

    INTERNET_OPEN_TYPE_PROXY, // access

    "ftp-gw", // proxy server

    NULL, // defaults

    0); // synchronous



    hFTPSession = ConnectToFtpServer(hInternetSession,
    "ftp.microsoft.com"
    NULL, // Use anonymous username
    NULL, // Use e-mail name password
    (LPVOID)&dwContext);

    // find first .ZIP file
    hFileConnection = ::FtpFindFirstFile(
    hFTPSession,
    "*.ZIP",
    &sWFD,
    0,
    0);
    if (hFileConnection != (HINTERNET)NULL)
    {
    ::FtpSetCurrentDirectory(hFTPSession, "/BIN");

    while (bResult)
    {
    // Create file specs.
    InputSpec = "ftp://ftp.infosite.com/BIN/";
    InputSpec = InputSpec + sWFD.cFileName;
    OutputSpec = "c:\zipfiles\";
    OutputSpec = OutputSpec + sWFD.cFileName;

    // Transfer the file.
    bResult = ::FtpGetFile(
    hFTPSession,
    InputSpec,
    OutputSpec,
    FALSE,
    FILE_ATTRIBUTE_NORMAL,
    FTP_TRANSFER_TYPE_BINARY,
    0);


    // Get next file.
    bResult = ::InternetFindNextFile(
    hFileConnection,
    &sWFD);
    }
    }
    // Close down all connections.
    ::InternetCloseHandle(hFTPSession);
    ::InternetCloseHandle(hInternetSession);

  2. #2
    Join Date
    Nov 2003
    Location
    Bangalore
    Posts
    78

    Re: FtpGetFile() fails!

    I got the InternetGetLastResponseInfo(). But the buffer it returns is empty.

    With Regards,
    A.Ilamparithi.

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: FtpGetFile() fails!

    There is an MS sample FTPTREE: FTPTREE: Displays the Structure and Content of an FTP Site
    Try to use it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured