Dart Ftp Control
Get Method
Specifies the Universal Resource Locator. This parameter is modeled after IE 4.0.
Optional String specifying the destination (local) file name, or an undimensioned String, Byte array, or DartStream object that is dynamically expanded and filled with file data. If not specified or NULL, the filename from the URL (without path) is used in the local default directory. If the Type value is ftpZip, and the file is a valid zip file, the file will be decompressed into the directory specified in Result or into the local directory if the value of Result is NULL.
Optional. Specifies the number of characters that should be skipped. If a file transfer was previously interrupted, the Marker parameter can be used to start at an exact location, so the entire file does not have to be transferred. See the Restart property for more information. If the server does not support restarts and you specify Marker, the entire file is retrieved and the Restart property is set to False.
Optional. Use in conjunction with Marker to specify the number of bytes to be skipped in a large file. If a file transfer was previously interrupted, Marker and MarkerHigh can be used to start at an exact location greater than 2^31.
Description
Log in, get a file, and log out in one step.
Syntax
Visual Basic
Public Sub Get( _
   ByVal Url As String, _
   Optional ByRef Result As Variant, _
   Optional ByVal Marker As Long = 0, _
   Optional ByVal MarkerHigh As Long = 0 _
) 
Parameters
Url
Specifies the Universal Resource Locator. This parameter is modeled after IE 4.0.
Result
Optional String specifying the destination (local) file name, or an undimensioned String, Byte array, or DartStream object that is dynamically expanded and filled with file data. If not specified or NULL, the filename from the URL (without path) is used in the local default directory. If the Type value is ftpZip, and the file is a valid zip file, the file will be decompressed into the directory specified in Result or into the local directory if the value of Result is NULL.
Marker
Optional. Specifies the number of characters that should be skipped. If a file transfer was previously interrupted, the Marker parameter can be used to start at an exact location, so the entire file does not have to be transferred. See the Restart property for more information. If the server does not support restarts and you specify Marker, the entire file is retrieved and the Restart property is set to False.
MarkerHigh
Optional. Use in conjunction with Marker to specify the number of bytes to be skipped in a large file. If a file transfer was previously interrupted, Marker and MarkerHigh can be used to start at an exact location greater than 2^31.
Remarks

Note: This method supports only UNIX-style file systems (forward slashes specify the file path).

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 file data and replies are received.

If URL specifies a directory, then Result is not used and the Listing property is filled with the listing.

If the Type is ftpZip and the file is a valid zip file, the file will be automatically decompressed into the local directory or the directory specified in Result. Be sure to use care when performing the operation. You will not be able to compare file names in your local directory to file names within the zip file, so any files with the same name will be automatically overwritten. The local directory is the current working directory for your application and can be changed by using the Visual Basic ChDir command. 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.

If you wish to use a DartStream object as Result, you must first add a reference to DartSock.dll.

Error Codes

This method may generate the following error code (refer to ErrorConstants for a complete list of error codes):

Example
This VB example shows how to log in (anonymously), get a file, and then log out in one line of code.
Private Sub Command1_Click()
	On Error GoTo OnError ' use intrinsic error handling
	Dim FileBuf As String ' local scope allowed because Timeout > 0
	' Login as anonymous and save the data to a buffer
	Ftp1.Get "ftp://ftp.dart.com/ftpchallenge.txt", FileBuf
	Text1.Text = FileBuf ' show file data to user
	Exit Sub
OnError: ' Any error jumps here
	Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description
End Sub
This example demonstrates logging in, getting a compressed file, and decompressing it locally all in one step.
Private Sub Command1_Click()
	On Error GoTo onError
	' Set Type to ftpZip, this will cause the file to be automatically 
	' uncompressed after transfer
	Ftp1.Type = ftpZip
	' Login, get, and uncompress a zip file in one step
	Ftp1.Get "ftp://user:pass@myserver/home/zippedfile.zip", "c:\temp"
	Exit Sub
onError:
	Debug.Print Err.Description
End Sub
See Also

Ftp Object  | Ftp Members


PowerTCP SSL for ActiveX Documentation Version 2.2.1
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic