Results 1 to 3 of 3

Thread: How to check if a file exists, if doesn't exists, then download it?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2007
    Posts
    145

    How to check if a file exists, if doesn't exists, then download it?

    How to check if a file exists, if doesn't exists, then download it?

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: How to check if a file exists, if doesn't exists, then download it?

    i believe it's like this.
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    On Error GoTo err
    
    Dim gifbyt() As Byte
    Dim i As Integer
    Dim fno As Long
    
    Inet1.Execute "http://www.codeguru.com/forum/images/cg-logo.gif", "GET"
    
    While Inet1.StillExecuting
        DoEvents
        'Wait for it to stop executing
    Wend
    
    If Inet1.GetHeader("Content-length") = "" Then
       MsgBox "File Not found"
    Else
    
        gifbyt() = Me.Inet1.OpenURL("http://www.codeguru.com/forum/images/cg-logo.gif", icByteArray)
        'Ritrived the gif file as Bytes of Array
        
        'Creating an empty gif file and write the bytes in to it.
        fno = FreeFile()
        Open "c:\logo.gif" For Binary Access Write As #fno
        Put #fno, , gifbyt()
        Close #fno
        MsgBox "Downlod Complete"
       
    End If
    
    
    Exit Sub
    err:
    MsgBox err.Description
    
    End Sub
    Last edited by Fazi; Jan 6th, 2008 at 11:09 AM.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2007
    Posts
    145

    Re: How to check if a file exists, if doesn't exists, then download it?

    Oh! Thx!

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