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

VB FTP COMMANDS

Status
Not open for further replies.

pyttviper

MIS
May 15, 2001
37
0
0
US
I have a problem.

I have looked at all of the articles i can find about FTPing from a VB program, but I am still unclear on how to implement it in the code.

The steps I want to accomplish are:

connect to a server (username, password)
go to a directory
put a file in that directory from the local machine.

i have a batch file that does this now but I am finding it hard to put those commands in VB. If any one has a simple explanation or code snipet I would really appriciate it.


Thanks

Dan0
 
You might want to try something like the following

Add the Microsoft Internet Transfer Control to the project (Inet1)


Dim FTPError As Boolean ' global variable

Private Sub SendFTP()

Dim FromFile As String
Dim ToFile As String

FromFile = "c:\dirname\dirname\filename"
ToFile = "\filename"
FTPError = False

Inet1.AccessType = icUseDefault
Inet1.URL = &quot;ftp://&quot; & &quot;<put ip address or URL here>&quot; & &quot;/&quot;
Inet1.UserName = UserName
Inet1.Password = Password

fStr_FTPCommand = &quot;PUT &quot; & FromFile & &quot; &quot; & ToFile
Inet1.Execute , fStr_FTPCommand
Do While Inet1.StillExecuting
DoEvents
If (FTPError = True) Then
Inet1.Cancel
End If
Loop

End Sub

Private Sub Inet1_StateChanged(ByVal rInt_FTPState As Integer)

Dim lStr_ErrorMsg As String

Select Case rInt_FTPState
Case icError
lStr_ErrorMsg = &quot;Code: &quot; & Inet1.ResponseCode & &quot; : &quot; & Inet1.ResponseInfo
MsgBox lStr_ErrorMsg
FTPError = True
Inet1.Cancel

Case icResponseCompleted
Case icNone
Case icResolvingHost
Case icHostResolved
Case icConnecting
Case icConnected
Case icRequesting
Case icRequestSent
Case icReceivingResponse
Case icResponseReceived
Case icDisconnecting
Case icDisconnected
End Select

End Sub
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top