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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp session 1

Status
Not open for further replies.

QTip

Programmer
Mar 7, 2001
66
BE
Hellow,

I need to open an ftp session in VB6 and send some files to that FTP. I already searched the site here for solutions, but those I found didn't work for me.
I use the Inet component.
I tried it as following, but nothing works.

Can somebody help me, thank you!

Private Sub Command2_Click()

With Inet1
.AccessType = icUseDefault
.Protocol = icFTP
.UserName = "myusername"
.Password = "mypassword"
.RemoteHost = "TheRemoteHost"
.RemotePort = "21"
.Execute "SEND C:\temp\design.txt"
End With

End Sub
 
Two things.

1- GET a good FTP control like the Mabry one. (Other options on
2- the execute method is incomplete. the correct format is
.Execute url, operation, data, requestHeaders
as you are ommiting the URL your command should look like

.execute , "SEND C:\temp\design.txt" 'Note the "," after the execute


I strongly advise you to try and get one of the FTP's mentioned on 1 though.


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
ok, I'll try that.

But isn't there any possible way for working with Inet?
Because the others aren't for free... and you know how bosses are... "make it work, ... and use the software we have!"

Frederico, I've tried your solution, but it still doesn't work. I don't get any error message, but when I look on the remote computer, no file has been uploaded.

We have also a license for ws-ftp pro, can I use that in vb to access the remote host?

Thnx for any replies!
 
ws-ftp pro can also be used but you need to buy a development license ($195.00) and depending on your version you may also need to buy an upgrade license for your existing product.

I have been using Mabry FTP control for 5 years now, and I do recomend it, as the price is not that high, and it has so much more than the Inet control that it is just worth it ($189.00).
As I said others may work as well or better than this.
If someone has had experiences with others please post their opinion.


------------
try

Private Sub Command2_Click()

With Inet1
.AccessType = icUseDefault
.Protocol = icFTP
.UserName = "myusername"
.Password = "mypassword"
.RemoteHost = "TheRemoteHost"
.RequestTimeout = 600
.RemotePort = "21"
.Execute , "SEND C:\temp\design.txt design.txt"
End With

End Sub


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
ok, I found a way that works:

With Inet1
.Cancel
.Protocol = icFTP
.URL = "ftp://hostname"
.UserName = "login"
.Password = "password"
.Execute , "PUT c:\temp\design.txt /test/design.txt"
End With

But offcourse, this is not the end.
I'm gonna make it a little harder. :)
What I really need to do is copy all the files from a directory to a remote pc (with the Inet control).
The program search for files in the directory. The .Execute is in a loop so that every file get passed by the Execute command.
But offcourse there is a problem... Next error: Still executing last request

How can I help this?

Thnx!
 
Try something along these lines

New sub with

While not all files processed
(get next file name)
While Inet1.StillExecuting = True
DoEvents
Wend
Call copyfile(origin, destination)
wend

Private Sub copyfile(origin As String, destination As String)
With Inet1
.AccessType = icUseDefault
.Protocol = icFTP
.UserName = "myusername"
.Password = "mypassword"
.RemoteHost = "TheRemoteHost"
.RequestTimeout = 600
.RemotePort = "21"
.Execute , "SEND " & origin & " " & destination
End With
end sub


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
the Do While Inet1.StillExecuting = True did it.
thnx man!!
 
ok, something extra :)

When the data is being send, the date in the source directory gets deleted. Otherwise the source directory will get way too large.
ok until this point.

But I want to have a control on it. When there is an ftp error and the file has not been send, the source file can't be deleted. The file has to be send again next time the program runs.

How can I intercept the errors from the ftp?
 
QTip did you ever figure out how to prevent the source data from being deleted if it wasn't sucessfully uploaded? I am facing the same problem.

Thanks,
Wendy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top