Dim ftp As New ChilkatFtp2Dim success As Long' Any string unlocks the component for the 1st 30-days. success = ftp.UnlockComponent("Anything for 30-day trial") If (success <> 1) Then MsgBox ftp.LastErrorText Exit Sub End Ifftp.Hostname = "ftp.chilkatsoft.com" ftp.Username = "****" ftp.Password = "****"' The default data transfer mode is "Active" as opposed to "Passive".' Connect and login to the FTP server. success = ftp.Connect() If (success <> 1) Then MsgBox ftp.LastErrorText Exit Sub End If' Change to the remote directory where the file will be uploaded. success = ftp.ChangeRemoteDir("junk") If (success <> 1) Then MsgBox ftp.LastErrorText Exit Sub End If' Upload a file. Dim localFilename As String localFilename = "hamlet.xml" Dim remoteFilename As String remoteFilename = "hamlet.xml"success = ftp.PutFile(localFilename,remoteFilename) If (success <> 1) Then MsgBox ftp.LastErrorText Exit Sub End Ifftp.Disconnect MsgBox "File Uploaded!"我帮你搜了一个。 更多参考如下: http://www.example-code.com/vb/ftp.asp
你的是用第三方控件实现的。。不是我所需要的。我是要用API来实现的。
这回是api 了 比较长你自己下去吧!http://www.devx.com/getHelpOn/10MinuteSolution/20373#codeitemarea只给你沾点:part (1) Attribute VB_Name = "WinInetAPI" Option ExplicitConst ErrFolder As String = "\ErrorLogs" 'folder Name for errorlog text files Const ErrFile As String = "\errlog" 'errorlog text File Name Private iCount As Long 'error message counterPublic Const sSlash = "/"Public Const MAX_PATH As Long = 260 Public Const FILE_ATTRIBUTE_ARCHIVE = &H20Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0 ' use registry configuration Public Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net Public Const INTERNET_OPEN_TYPE_PROXY = 3 ' via named proxy Public Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 ' prevent using java/script/INSPublic Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections Public Const INTERNET_FLAG_RELOAD = &H80000000 ======================================================================================== part (2) VERSION 1.0 CLASS BEGIN MultiUse = -1 'True Persistable = 0 'NotPersistable DataBindingBehavior = 0 'vbNone DataSourceBehavior = 0 'vbNone MTSTransactionMode = 0 'NotAnMTSObject END Attribute VB_Name = "clsFTP" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = False Attribute VB_Exposed = False '******************************************************************************** ' Class: clsFTP '-------------------------------------------------------------------------------- ' Description: ' This class allows to connect to FTP site using WinInet API calls ' and download files from FTP Directory '--------------------------------------------------------------------------------- ' Methods: OpenConnection - opens FTP connection, gets internet Handle ' CloseConnection - closes FTP connection ' DownloadFile - downloads file from FTP site to defined destination ' UploadFile - copies a file from your local machine to a FTP site ' DeleteFile - deletes a file from a FTP site ' RenameFile - renames a file on a FTP site ' CheckFile - checks if specified file exist on FTP site ' EnumDirectory - Returns a list of files and folders in a path ' ChangeDirectory - Changes the current directory
success = ftp.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
MsgBox ftp.LastErrorText
Exit Sub
End Ifftp.Hostname = "ftp.chilkatsoft.com"
ftp.Username = "****"
ftp.Password = "****"' The default data transfer mode is "Active" as opposed to "Passive".' Connect and login to the FTP server.
success = ftp.Connect()
If (success <> 1) Then
MsgBox ftp.LastErrorText
Exit Sub
End If' Change to the remote directory where the file will be uploaded.
success = ftp.ChangeRemoteDir("junk")
If (success <> 1) Then
MsgBox ftp.LastErrorText
Exit Sub
End If' Upload a file.
Dim localFilename As String
localFilename = "hamlet.xml"
Dim remoteFilename As String
remoteFilename = "hamlet.xml"success = ftp.PutFile(localFilename,remoteFilename)
If (success <> 1) Then
MsgBox ftp.LastErrorText
Exit Sub
End Ifftp.Disconnect MsgBox "File Uploaded!"我帮你搜了一个。
更多参考如下:
http://www.example-code.com/vb/ftp.asp
Attribute VB_Name = "WinInetAPI"
Option ExplicitConst ErrFolder As String = "\ErrorLogs" 'folder Name for errorlog text files
Const ErrFile As String = "\errlog" 'errorlog text File Name
Private iCount As Long 'error message counterPublic Const sSlash = "/"Public Const MAX_PATH As Long = 260
Public Const FILE_ATTRIBUTE_ARCHIVE = &H20Public Const INTERNET_OPEN_TYPE_PRECONFIG = 0 ' use registry configuration
Public Const INTERNET_OPEN_TYPE_DIRECT = 1 ' direct to net
Public Const INTERNET_OPEN_TYPE_PROXY = 3 ' via named proxy
Public Const INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY = 4 ' prevent using java/script/INSPublic Const INTERNET_FLAG_PASSIVE = &H8000000 ' used for FTP connections
Public Const INTERNET_FLAG_RELOAD = &H80000000
========================================================================================
part (2)
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "clsFTP"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'********************************************************************************
' Class: clsFTP
'--------------------------------------------------------------------------------
' Description:
' This class allows to connect to FTP site using WinInet API calls
' and download files from FTP Directory
'---------------------------------------------------------------------------------
' Methods: OpenConnection - opens FTP connection, gets internet Handle
' CloseConnection - closes FTP connection
' DownloadFile - downloads file from FTP site to defined destination
' UploadFile - copies a file from your local machine to a FTP site
' DeleteFile - deletes a file from a FTP site
' RenameFile - renames a file on a FTP site
' CheckFile - checks if specified file exist on FTP site
' EnumDirectory - Returns a list of files and folders in a path
' ChangeDirectory - Changes the current directory