|
可以使用Catalyst File Transfer Control 4.0 (SP3)控件
Private Sub Command6_Click() '上传
Dim strLocalFullName As String
Dim strRemoteFullName As String
Dim lResult As Long
strLocalFullName = Me.TxtLocalName
strRemoteFullName = FullName(TxtRemoteFolder, TxtRemoteFileName)
FileTransfer2.ServerType = GetServerType
FileTransfer2.ServerName = Me.TxtSeverName
FileTransfer2.ServerPort = 21
'以下根据需要决定
'FileTransfer2.Timeout = CLng(Val(editTimeout.Text))
'FileTransfer2.UserName = Trim(editUserName.Text)
'FileTransfer2.Password = Trim(editPassword.Text)
lResult = FileTransfer2.Connect
If lResult <> 0 Then
MsgBox "Connection failed" & vbCrLf & FileTransfer21.LastErrorString
End If
lResult = FileTransfer2.PutFile(strLocalFullName, strRemoteFullName)
If lResult <> 0 Then
MsgBox "Transfer failed" & vbCrLf & FileTransfer2.LastErrorString
End If
lResult = FileTransfer2.Disconnect
End Sub
Private Function FullName(strDir As String, strFile As String) As String
Dim strDelim As String
Dim strLastChar As String
strDelim = "\"
If InStr(strDir, "/") > 0 Then strDelim = "/"
strLastChar = Right(strDir, 1)
If strLastChar = strDelim Then
FullName = strDir & strFile
Else
FullName = strDir & strDelim & strFile
End If
End Function
|
|