Skeen
Sep 27th, 2000, 07:29 AM
Hiyas
I'm trying to use the internet controll in VB to download files from an ftp site. I can download a list of directories from the site but when I adapted the code it all went pear shaped - can anyone help - Below is a snippett of code and th problem occurs with nasty memory addressing error at thi line:
"FindNextHandle = FindNextFile(FindHandle, " _
& " FindData)" - And I've no idea whats happening.
Can anyone help?
Cheers 'n' Beers
SKEEN
CODE::
Inet1.URL = "ftp://ftp.site.co.uk"
Inet1.UserName = "Username"
Inet1.Password = "Password"
Inet1.Execute "GET File.txt C:\File.txt"
FileNumber = 1
'On Error Resume Next
TotalFiles = 0
Count = 0
'DirPath = "E:\All_Ed's_shite\Opal_ftp_data\"
DirPath = Inet1.URL 'OpenURL("ftp://acquistftp:1cc2d3t4@ftp.opal.callmanagement.co.uk/Daily Files/CDRs/")
FileSpec = "*.CRB"
FindHandle = FindFirstFile(DirPath & FileSpec, FindData)
' Loop Through Files
If FindHandle <> 0 Then
Do
DoEvents
FindNextHandle = FindNextFile(FindHandle, " _
& " FindData)
If FindNextHandle <> 0 Then
If FindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
' Its a directory
If Left$(FindData.cFileName, 1) <> "." And Left$(FindData.cFileName, 2) <> ".." Then
filestring = DirPath & Trim$(FindData.cFileName) & "\"
End If
Else
filestring = DirPath & Trim$(FindData.cFileName)
TotalFiles = TotalFiles + 1
End If
Else
Exit Do
End If
Loop
End If
ReDim Filenames(1 To TotalFiles) As String
I'm trying to use the internet controll in VB to download files from an ftp site. I can download a list of directories from the site but when I adapted the code it all went pear shaped - can anyone help - Below is a snippett of code and th problem occurs with nasty memory addressing error at thi line:
"FindNextHandle = FindNextFile(FindHandle, " _
& " FindData)" - And I've no idea whats happening.
Can anyone help?
Cheers 'n' Beers
SKEEN
CODE::
Inet1.URL = "ftp://ftp.site.co.uk"
Inet1.UserName = "Username"
Inet1.Password = "Password"
Inet1.Execute "GET File.txt C:\File.txt"
FileNumber = 1
'On Error Resume Next
TotalFiles = 0
Count = 0
'DirPath = "E:\All_Ed's_shite\Opal_ftp_data\"
DirPath = Inet1.URL 'OpenURL("ftp://acquistftp:1cc2d3t4@ftp.opal.callmanagement.co.uk/Daily Files/CDRs/")
FileSpec = "*.CRB"
FindHandle = FindFirstFile(DirPath & FileSpec, FindData)
' Loop Through Files
If FindHandle <> 0 Then
Do
DoEvents
FindNextHandle = FindNextFile(FindHandle, " _
& " FindData)
If FindNextHandle <> 0 Then
If FindData.dwFileAttributes And FILE_ATTRIBUTE_DIRECTORY Then
' Its a directory
If Left$(FindData.cFileName, 1) <> "." And Left$(FindData.cFileName, 2) <> ".." Then
filestring = DirPath & Trim$(FindData.cFileName) & "\"
End If
Else
filestring = DirPath & Trim$(FindData.cFileName)
TotalFiles = TotalFiles + 1
End If
Else
Exit Do
End If
Loop
End If
ReDim Filenames(1 To TotalFiles) As String