Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inet execute method using LS for list

Status
Not open for further replies.

hovercraft

Technical User
Jun 19, 2006
236
US
Sorry to be a pain, but I've looked for some documention on using inet ( msinet.ocx ) and have come up all but empty.
I'm trying to use inet to get a list of all files in a directory on a ftp server.

I'm using the following code to upload to the server and was wondering how the syntax should look to use ls instead of put or get.

Function UploadFile(ByVal HostName As String, _
ByVal UserName As String, _
ByVal Password As String, _
ByVal LocalFileName As String, _
ByVal RemoteFileName As String) As Boolean
On Error GoTo ErrHandler

Dim FTP As Inet

Set FTP = New Inet
With FTP
.Protocol = icFTP
.RemoteHost = HostName
.UserName = UserName
.Password = Password
.Execute .URL, "Put " + LocalFileName + " " + RemoteFileName
Do While .StillExecuting
DoEvents
Loop
UploadFile = (.ResponseCode = 0)
End With

ExitHere:
On Error Resume Next
Set FTP = Nothing
Exit Function
ErrHandler:
Debug.Print Err, Err.Description
Resume ExitHere
End Function

Any assistance would be appreciated.
Thanks,
Hovercraft
 
The ftp syntax is:
ls remote-directory local-file

Note: be sure that the interactive prompting is off.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PH,

If I understand, this would be:

Function GetFileList(ByVal HostName As String, _
ByVal UserName As String, _
ByVal Password As String, _
ByVal LocalFileName As String, _
ByVal RemoteDirectoryName As String) As Boolean
On Error GoTo ErrHandler

Dim FTP As Inet

Set FTP = New Inet
With FTP
.Protocol = icFTP
.RemoteHost = HostName
.UserName = UserName
.Password = Password
.Execute .URL, "ls " + RemoteDirectoryName + " " + LocalFileName
Do While .StillExecuting
DoEvents
Loop
ListFile = (.ResponseCode = 0)
End With

ExitHere:
On Error Resume Next
Set FTP = Nothing
Exit Function
ErrHandler:
Debug.Print Err, Err.Description
Resume ExitHere
End Function
 
I have found some info over at microsoft. They suggest to use "Dir" and then to use .GetChunk in order to get the file names.

I'm completely lost on this one.
How would I use .GetChunk inside of a function that only returns a boolean?

What I'm ultimatly trying to accomplish is just to copy all files from a ftp directory.

any suggestions?

Thanks,
Hovercraft
 
copy all files from a ftp directory
What about mput (or mget) ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Well, see that seems to be my problem. I'm not sure if I can simply replace
Code:
.Execute .URL, "Put " + LocalFileName + " " + RemoteFileName
with
Code:
.Execute .URL, "MGet"
Is that all I have to do?
 
I'd try this:
.Execute .URL, "MGet *"

note: be sure that the interactive prompting is off

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Inet doesn't support MGet.

Do you have any other suggestions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top