|
-
Nov 9th, 2004, 12:03 PM
#1
Thread Starter
Lively Member
download cfg file
how can i download a cfg file
i try it with this script but it would not work
VB Code:
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
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Load()
DownloadFile "http://84.244.130.208/cod/main/dedicated.cfg", "c:\dedicated.cfg"
End Sub
thanks for the help
-
Nov 9th, 2004, 02:26 PM
#2
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.
-
Nov 9th, 2004, 09:38 PM
#3
Thread Starter
Lively Member
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
-
Nov 10th, 2004, 01:26 AM
#4
can't you download it and THEN read it?
-
Nov 10th, 2004, 08:44 AM
#5
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|