CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 1999
    Posts
    4

    How to use "FtpFindFirstFile" API ?

    Hi,
    I want to check whether the files have downloaded properly, for that I need to check the file size of both the files ( ie. the local file and the file in the FTP server).

    I need to pass the file name and then I need to get the file size.

    I have used it as :

    Dim Connect As Long, Session As Long
    Dim Check As Boolean, retVal As Long
    Dim FFFile As WIN32_FIND_DATA
    Dim FName As String

    Connect = InternetOpen("MyFTPControl", 1, vbNullString, vbNullString, 0)
    Session = InternetConnect(Connect, txtHost, 0, txtUser, txtPass, 1, 0, 0)
    If Session = 0 Then GoTo ErrHandler
    Check = FtpSetCurrentDirectory(Session, "/outbox/backup" + vbNullString)
    If Check = False Then GoTo ErrHandler
    'FFFile.cFileName = "AR1011.tif" & vbNullString
    FName = "ar1011.tif" & vbNullString
    retVal = FtpFindFirstFile(Session, FName, _
    FFFile, 0, 0)

    If retVal = 0 Then GoTo ErrHandler '(*)
    If retVal > 0 Then 'statusFileSize > 0 Then
    ' doing the necessary action
    End If

    I am geting the error at (*) this marked line.

    I am not able to get the exact syntax and the values of the parameters that this FtpFindFirstFile API takes. Can any one help me in this?

    Thanx in advance.

    Britto


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: How to use "FtpFindFirstFile" API ?

    I'd pass Err.lastDLLError to the FormatMessage API after calling FtpFindFirst... to get a human-readable explanation of the error code.
    That's better than guessing ;-)


  3. #3
    Join Date
    Nov 1999
    Posts
    4

    Re: How to use "FtpFindFirstFile" API ?

    Hi

    In my ErrHandler I have written the following code:

    Dim ErrNo As Long
    Dim lFmtMsg As Long
    Dim errMsg As String

    ErrNo = Err.LastDllError
    errMsg = Space(1024)
    lFmtMsg = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, ByVal 0&, _
    ErrNo, 0&, errMsg, Len(errMsg), ByVal 0&)

    MsgBox "Error No :" & ErrNo & vbNewLine & "Error Msg :" & errMsg

    The error number is 12003 and no error message. Can you cay what can be the errro message and any way to rectify it.

    Thanx.

    Britto



  4. #4
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: How to use "FtpFindFirstFile" API ?

    That's an extended error from the WinInet DLL - take a look at my code sample at http://codeguru.developer.com/vb/articles/1852.shtml - it shows how to handle that error and others that can be generated from the DLL.


    Chris Eastwood

    CodeGuru - the website for developers
    http://codeguru.developer.com/vb

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