Results 1 to 9 of 9

Thread: Files on the internet

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Lincolnshire, UK
    Posts
    111
    I have a small problem with downloading files from the net. I am trying to create an automatic download system from the net that will see if a file exists and then copy it to a particular folder. The problem is that I cannot get the system to copy a file, even if I specify a file which I know exists

    Please help!

    Cheers

    Chris

  2. #2
    Lively Member
    Join Date
    Nov 2000
    Posts
    73
    hi,
    try this piece of code
    declaration

    Public Declare Function URLDownloadToFile Lib "urlmon" Alias _
    "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
    ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) _
    As Long

    'Code
    Private Sub Command1_click()
    dim llRetVal as Integer
    llRetVal = URLDownloadToFile(0, SourceFileName, _
    TargetFileName, 0, 0)
    End Sub

    if any problem call back this code will download the file on clicking on the command button afte running the example check in ur system it wont pop up any message

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Talking Such a gooc API call.

    Wow... that very good API function call. Downlaod a file without using any iNet and webbrowser activex control. I like this function.



  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 1999
    Location
    Lincolnshire, UK
    Posts
    111
    Cheers Krigans, since you seem to be a bit of a guru, any chance you know how to check if a file exists on the web?

    Cheers

    Chris

  5. #5
    Guest
    To check if a file exists on the internet. You can use the Inet Control to check for the 404 Error.

    Code:
    Private Sub Command1_Click()
    Text1.Text = Inet1.OpenURL("http://www.site.com/site.htm")
    DoEvents
    If InStr(Text1.Text, "404 Not Found") Then
    MsgBox "Site does not exist!"
    Else
    MsgBox "Site exists!"
    End If
    End Sub

  6. #6
    Lively Member
    Join Date
    Nov 2000
    Posts
    73
    hi,
    thanks chrisfricke,
    but no guru and all there's a way for it using wininet.dll but it's a bit lengthy process
    as there are lot's of api's and constant declartions
    so i will get back to u with the code which u require

    within a day or 2

  7. #7
    Lively Member
    Join Date
    Nov 2000
    Posts
    73
    hi Mathew ,
    there's problem with inet control is that it works fine but conected to the application twice or thrice ur application will go for a toss

  8. #8
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Red face Downloading status.

    Juz found that this API function can not return the downloading status, I mean is the percentage of the entire file being downloaded into the local PC.

    Is there anyway to retrieve this information? Because it will a good information to the user.

    Originally posted by krigans
    hi,
    try this piece of code
    declaration

    Public Declare Function URLDownloadToFile Lib "urlmon" Alias _
    "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
    ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) _
    As Long

    'Code
    Private Sub Command1_click()
    dim llRetVal as Integer
    llRetVal = URLDownloadToFile(0, SourceFileName, _
    TargetFileName, 0, 0)
    End Sub

    if any problem call back this code will download the file on clicking on the command button afte running the example check in ur system it wont pop up any message

  9. #9
    Lively Member
    Join Date
    Nov 2000
    Posts
    73
    sorry i'm not aware of the method

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