Ftp Object : Put Method |
Visual Basic |
---|
Public Sub Put( _ ByVal Url As String, _ Optional ByVal Source As Variant, _ Optional ByVal Marker As Long = 0, _ Optional ByVal MarkerHigh As Long = 0 _ ) |
Note Only UNIX-style file systems are supported by this method (forward slashes specify the file path).
This method establishes a connection and if necessary, sequences the following commands (refer to the CommandConstants topic for more information on these commands):
URL format (note that file path is relative to the root directory):
ftp://username:password@hostname:port/filepath
"ftp://" is optional, and can be omitted
"username:password@", if omitted, defaults to "anonymous:powertcp@"
":port", if omitted, defaults to "21"
Always blocks until complete or throws an error. Progress and Progress64 events fire as each buffer is sent and any reply is received.
If Type is ftpZip the file or files specified in Source will be automatically compressed and transferred to the remote directory and file name identified in the URL. The URL must contain the name of the remote file. The file placed on the remote server will have an extension of .zip. The Source parameter is not optional if the ftpZip type is used. For more advanced zip functionality, please look at PowerTCP Zip Compression for ActiveX at www.dart.com.
MarkerHigh should be set to the value of the restart position divided by 2^31 (2147483648). Marker should be set to the remainder of this operation.
A ptInvalidParam2 error will occur if the size of the source data is larger than 2^31 and is NOT a file.
If you wish to use a DartStream object as Result, you must first add a reference to Dart FTP Utils.
This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):
Private Sub Command1_Click() On Error Goto OnError ' use intrinsic error handling Dim FileBuf As String ' local scope allowed because Timeout > 0 ' Login to the user account and store File.txt Ftp1.Put "ftp://user:password@ftp.dart.com/users/user/File.txt", "c:\File.txt" Exit Sub OnError: ' Any error jumps here Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description End Sub
Private Sub Command1_Click() On Error Goto OnError ' Set Type to ftpZip, this will cause the file to be automatically zipped ' before storing Ftp1.Type = ftpZip ' Login, zip, and store a file in one step Ftp1.Put "ftp://user:pass@myserver/home/zippedfile.zip", "c:\test.txt" Exit Sub OnError: Debug.Print Err.Description End Sub