|
-
Sep 27th, 2000, 09:03 AM
#1
Thread Starter
Addicted Member
Hiyas
I have some code which I got from a tutorial which downloads a directory listing from an ftp site, I want to convert the code so that it downloads files but the examples I've found won't work - can anyone tell me hoe to change to file transfer - tutorials seem to think ist easy - but I can't get my head round it!
Heres my code:
Private Sub Command1_Click()
Inet1.URL = "ftp://ftp.somesite.com/directory/"
Inet1.UserName = "Username"
Inet1.Password = "Password"
Inet1.Execute , "DIR"
'If I comment out the line above & introduce th line below -'I should transfer a file - but It won't work
'can anyone tell me whats wrong?
'Inet1.Execute , "GET file.txt C:\file.txt"
End Sub
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData As Variant ' Data variable.
Select Case State
' ... Other cases not shown.
Case icError ' 11
' In case of error, return ResponseCode and
' ResponseInfo.
vtData = Inet1.ResponseCode & ":" & _
Inet1.ResponseInfo
Case icResponseCompleted ' 12
Dim strData As String: strData = ""
Dim bDone As Boolean: bDone = False
' Get first chunk.
vtData = Inet1.GetChunk(1024, icString)
DoEvents
Do While Not bDone
strData = strData & vtData
' Get next chunk.
vtData = Inet1.GetChunk(1024, icString)
DoEvents
If Len(vtData) = 0 Then
bDone = True
End If
Loop
MsgBox State 'strData
End Select
End Sub
Cheers 'n' beers
Skeen
"It wasn't the booze that made me snooze, It was the Gin that did me in!"
-
Sep 28th, 2000, 12:55 AM
#2
Lively Member
-
Sep 28th, 2000, 10:03 AM
#3
Thread Starter
Addicted Member
HI DJ
I checked out the link but I'm still having no success.
I resorted back to basics to start again - but I'm screwing that up now.
I pt a textbox, button and Inet1 control on a form, the inthe command button sud I typed
Text1.Text = Inet1.OpenURL __
_ ("ftp://ftp.microsoft.com/disclaimer.txt")
According to my books, the disclaimer should be displayed in the text box, but it isn't - can you suggest any sollution?
The Inet1 control is set up correctly - I'm completely lost!
Cheers
Skeen
"It wasn't the booze that made me snooze, It was the Gin that did me in!"
-
Sep 28th, 2000, 10:12 AM
#4
Frenzied Member
Strange, what's happening then?
Do you get any errors? (Request Timed out?)
When opening in IE I get the disclaimer.
THE INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESSED
OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY
DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL,
CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES,
EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO
NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR
CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING
LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1993.
I can't test it with the Inet now but report any errors and I may be able to help you later
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 29th, 2000, 04:21 AM
#5
Thread Starter
Addicted Member
HI Jop
I get the same when viewing through a browser,
but I think it times out when I try to run the VB.
I got a friend to try it and he had the same problem.
If you have any ideas I really appreciate the help?
Thanx
Skeen
"It wasn't the booze that made me snooze, It was the Gin that did me in!"
-
Sep 29th, 2000, 07:32 AM
#6
Frenzied Member
hmmm.. You have to try other control in order to check if it's the ITC control.
You could:
1. Set the ITC.RequestTimeout a little higher
2. Use the Microsoft internet controls (webbrowser)
3. Use the FTP control from http://www.dart.com
4. Use the FTP control from http://www.vbaccelerator.com
5. Use http://codeguru.earthweb.com/vb/articles/1852.shtml
And if you only want to download (not browsing through a directory) specific files:
Code:
'[begin of code]
'Author: Brad Martinez
'Origin: http://www.mvps.org/vbnet/code/netwo...ledownload.htm
'Purpose: Download a file via the file-download dialog
'Version: VB5+
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2000 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' You are free to use this code within your own applications,
' but you are expressly forbidden from selling or otherwise
' distributing this source code without prior written consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long
Private Sub DownloadFile(Url As String)
Url = StrConv(Url, vbUnicode)
Call DoFileDownload(Url)
End Sub
'[end of code]
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
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
|