Ftp Object : Get Method |
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 _ ) |
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.
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 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
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