Dart Ftp Control
MGet Method
Optional. Specifies a list of files and directories to retrieve from the server. Wildcards are allowed, and multiple paths may be specified when separated by a space. Any path with a space must be enclosed within quotes (see Remarks below). Defaults to "".
Optional. Specifies the destination directory to store the retrieved files. Defaults to current directory.
Optional DartStrings Object. Filled with a list of files that were successfully retrieved.
Optional DartStrings Object. Filled with a list of files with corresponding errors that failed to be retrieved.
Description
Retrieve (get) multiple files or entire directory trees.
Syntax
Visual Basic
Public Sub MGet( _
   Optional ByVal Source As String = "", _
   Optional ByVal Destination As String = "", _
   Optional ByVal FilesTransferred As Variant, _
   Optional ByVal FileErrors As Variant _
) 
Parameters
Source
Optional. Specifies a list of files and directories to retrieve from the server. Wildcards are allowed, and multiple paths may be specified when separated by a space. Any path with a space must be enclosed within quotes (see Remarks below). Defaults to "".
Destination
Optional. Specifies the destination directory to store the retrieved files. Defaults to current directory.
FilesTransferred
Optional DartStrings Object. Filled with a list of files that were successfully retrieved.
FileErrors
Optional DartStrings Object. Filled with a list of files with corresponding errors that failed to be retrieved.
Remarks

Use this method to retrieve multiple files based on wildcards, file lists, or entire branches of a directory tree.

The following table shows some examples of wildcards:

Wildcard Meaning
* Get all files in the directory and the subdirectories.
*.* Get all files in the directory that contain a "." in the filename.
*.txt Get all files in the directory with filenames that end with ".txt".
Test* Get all files in the directory with filenames that begin with "Test"
*Test* Get all files in the directory that contain "Test" in the filename.

Warning Using wildcards may cause unexpected results. For example, getting ~/* is not the same as getting /*. Some systems may return different directory listings.

You may use a mixture of filenames and wildcards for Source. Filenames and wildcards may contain full paths, such as /Test/test.txt or /Test/*.txt. When Source is * then all subdirectories that do not exist on the local system will be created. The entire directory tree structure will be created and retrieved. Any existing files will be replaced unless file permissions do not allow, unless Overwrite is set to false. If a file in the file list specified by Source does not exist then the file and the corresponding error, separated by a space, is added to FileErrors and operation will continue on to the next file. Any file with a space in its name is wrapped with quotes ("). The following examples illustrate enclosing within quotes any path containing a space:

If Timeout is 0 before this method is called then the default value of 30 seconds will be used. If Timeout is greater than 0 then the value of Timeout will be used. A ptTimeout error will occur if no activity is received from the server within the timeout period.

If Destination is not a directory or does not exist then a ptInvalidParam2 error will occur.

The type specified by the Type property will be used to transfer all the files.

Notes

new:
total 12
-rw-r--r--   1 test     users          46 Jan 16 15:53 index.txt
drwxr-xr-x   2 test     users        4096 Jan 16 17:27 mslfiles/
-rw-r--r--   1 test     users          46 May  1 13:15 readme.txt

Error Codes

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

Example
This VB example demonstrates retrieving all files in the current server directory.
Private Sub Command1_Click()
	On Error Goto OnError ' use intrinsic error handling
	'Retrieve all files in the current server directory to the
	'current local directory.
	Ftp1.MGet
	Exit Sub
OnError: ' Any error jumps here
	Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description
End Sub
This VB example demonstrates retrieving all files based on a wildcard.
Private Sub Command1_Click()
	On Error Goto OnError ' use intrinsic error handling
	'Get all files, from the current server directory,
	'that end with .txt and put them in a local directory
	'called C:\TextFiles
	Ftp1.MGet "*.txt", "C:\TextFiles"
	Exit Sub
OnError: ' Any error jumps here
	Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description
End Sub
This VB example demonstrates retrieving an entire directory tree from the server.
Private Sub Command1_Click()
	On Error Goto OnError ' use intrinsic error handling
	' Get the entire Test directory, subdirectories included,
	' from the server and put it in the C:\NewFolder directory.
	Ftp1.MGet "Test/*", "C:\NewFolder"
	Exit Sub
OnError: ' Any error jumps here
	Debug.Print "Error #" + CStr(Err.Number) + ": " + 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