Results 1 to 5 of 5

Thread: download cfg file

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    download cfg file

    how can i download a cfg file

    i try it with this script but it would not work
    VB Code:
    1. Private 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
    2. Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
    3.     Dim lngRetVal As Long
    4.     lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    5.     If lngRetVal = 0 Then DownloadFile = True
    6. End Function
    7. Private Sub Form_Load()
    8. DownloadFile "http://84.244.130.208/cod/main/dedicated.cfg", "c:\dedicated.cfg"
    9. End Sub

    thanks for the help

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    does the URL work correctly from a browser window? Here is how I did it...

    Code:
    Option Explicit
    
    Private Sub Form_Load()
    
        DownLoadFromURL "http://somewhere..net/~some/", "somefile.txt"
        Unload Me
        
    End Sub
    
    Private Sub DownLoadFromURL(ByVal url As String, ByVal filename As String)
        '
        '   Download a file from a given URL
        '
        Dim bytes() As Byte
        Dim fnum As Integer
        Dim ftext As String
        '
        ' Download the file And load into Byte array
        '
        ftext = url & filename
        bytes() = Inet1.OpenURL(ftext, icByteArray)
    
        fnum = FreeFile
        '
        '   Write the downloaded file To disk
        '
        Open App.Path & "\" & filename For Binary Access Write As #fnum
        
        Put #fnum, , bytes()
        Close #fnum
        
    End Sub
    Last edited by dglienna; Nov 9th, 2004 at 02:29 PM.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86
    with this i can see the cfg file but the file is empty

    you can't read it online that's why i want to download it

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    can't you download it and THEN read it?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86
    that's what i try to do but with a script
    it's a file that is been used for an program online bbut i need to keep this files updated so i can chenge it but there are people who need to see this to that's why i want to download this file with a script

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