Results 1 to 7 of 7

Thread: FTP w/ Inet Control

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    How can I check to see if a file exists and what its size is on an FTP site? So far I have this:
    Code:
    With Inet1
       .Cancel
       .Protocol = icFTP
       .URL = "FTP://ftp.whatever.com"
       .UserName = "username"
       .Password = "password"
       .Execute , _
            "RENAME UPLOAD/old.txt UPLOAD/new.txt"
       DoLoop
       .Execute , "QUIT" 
    End With
    I want to make sure the file exists before I rename it and compare its size to the size of the file on my pc.
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    I don't believe you can retrieve remote file size using the inet control. But to check if the file exists, simply attempt to download/rename it and if it doesn't then you'll get an error and just have error handling to make sure your ftp keeps running.

    Gl,
    D!m
    Dim

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    The problem is that I DONT get an error when I attempt to rename a file that doesn't exist. I know there is a Inet.Execute "DIR...." command as well as a Inet.Execute "SIZE...." command, but I don't know how to use them and the VB Help is not helpful.
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  4. #4
    Guest
    Dim is right, I don't believe there is a way to get the file size of something you did not download to your computer.

    But you can check if it exists by trying to download it (or at least open it)..take a look at this thread for how to do that.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2000
    Location
    Philadelphia
    Posts
    123
    Thanks guys. I'll probably use Inet.Execute "Get ...." and download the file to a temp directory on my pc. Then I'll compare its size to the size of the original file that is already on my pc.
    VB6 & VC++6 Pro (SP4), Java (Sun JDK)

  6. #6
    Member
    Join Date
    Nov 1999
    Location
    Manila, Philippines
    Posts
    59

    Or you can do this

    dim s$
    Inet1.Execute Inet1.URL, "DIR myFilename.txt"
    s$ = inet1.GetChunk(1024)


    You can then check if your filename exists on the string passed returned by Getchuck method. this can only check if the file exists. hope this help
    Mikey
    A/P
    Using VB6 SP4 Enterprise Ed.

  7. #7
    Lively Member
    Join Date
    Jan 1999
    Location
    Karjalohja, Finland
    Posts
    123

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