Back to product page
- Introduction
- License agreement
- Classes
- Enumerations
- Exceptions
- WeOnlyDo.Client.SFTP
- Methods
- Properties
- Authentication
- Blocking
- BufferSize
- Compression
- Encryption
- EncryptionList
- HMacList
- Hostname
- KeepAlives
- KeyExchangeList
- LastError
- ListItem
- LocalPath
- Login
- MaxTransferRate
- Password
- Port
- PrivateKey
- ProxyHostname
- ProxyLogin
- ProxyPassword
- ProxyPort
- ProxyType
- RemoteIdentification
- RemotePath
- Resume
- State
- Timeout
- TransferMode
- TransferRate
- TransferTime
- Version
- Events
- How to get support?
GetFiles method
Downloads multiple files in a sequence, recursive.
Type
VoidSyntax
- C#
- VB.NET
public Void GetFiles();
public Void GetFiles(Int32 MaxLevel);
The GetFiles(MaxLevel) syntax has these parts:
public Void GetFiles(String LocalPath, String RemotePath, Int32 MaxLevel);
The GetFiles(LocalPath,RemotePath,MaxLevel) syntax has these parts:
public Void GetFiles(Int32 MaxLevel);
The GetFiles(MaxLevel) syntax has these parts:
MaxLevel | Specifies maximum number of subdirectory levels to copy. 0 for unlimited. |
public Void GetFiles(String LocalPath, String RemotePath, Int32 MaxLevel);
The GetFiles(LocalPath,RemotePath,MaxLevel) syntax has these parts:
LocalPath | Holds full path on local disk where files are downloaded. |
RemotePath | Holds full path on the server from where files are downloaded. |
MaxLevel | Specifies maximum number of subdirectory levels to copy. 0 for unlimited. |
public Sub GetFiles()
public Sub GetFiles(ByVal MaxLevel As Int32)
The GetFiles(MaxLevel) syntax has these parts:
public Sub GetFiles(ByVal LocalPath As String, ByVal RemotePath As String, ByVal MaxLevel As Int32)
The GetFiles(LocalPath,RemotePath,MaxLevel) syntax has these parts:
public Sub GetFiles(ByVal MaxLevel As Int32)
The GetFiles(MaxLevel) syntax has these parts:
MaxLevel | Specifies maximum number of subdirectory levels to copy. 0 for unlimited. |
public Sub GetFiles(ByVal LocalPath As String, ByVal RemotePath As String, ByVal MaxLevel As Int32)
The GetFiles(LocalPath,RemotePath,MaxLevel) syntax has these parts:
LocalPath | Holds full path on local disk where files are downloaded. |
RemotePath | Holds full path on the server from where files are downloaded. |
MaxLevel | Specifies maximum number of subdirectory levels to copy. 0 for unlimited. |
Remarks
This method will try to download complete directory structure of the server to local disk. You need to specify LocalPath argument that points to a directory where files are placed, and RemotePath that determines location from where are files copied.GetFiles will go and recursive copy directories and files - corresponding directory structure will also be created on local disk. If remote item that is copied is a symbolic link, it is resolved to appropriate file/folder whose contents are also copied.
wodSFTP.NET will go up to MaxLevel deep into recursion. Default value is 5 - meaning up to 5 subdirectory levels will be copied. You can specify any value for MaxLevel. If you specify 0, that means that no restriction exists for recursion depth - this is dangerous setting that could cause infinite loops to be created if remote system has symbolic links pointing back to other items that is already copied!
Before each item is copied, LoopItem event will be fired, specifying local name of the file/folder, its remote name (including full path in both cases), type of the item (file/folder/symbolic link) and will allow you to Skip the item so it is not copied locally at all. Make sure your logic for setting Skip = True is correct - if you skip creation of local directory and then try to download files to it, you may get more errors! Since GetFiles does not support wildcards (for example, you cannot specify "*.TXT" in GetFiles call), LoopItem is a place to determine if certain item matches your wildcard expression (if you have any), so you can skip files that doesn't match your criteria.
If an errors occurs during file download, LoopError event is fired holding error number and error description of the error. If you leave Args.Error exception argument in LoopError event as is - GetFiles operation will be aborted. If you change Args.Error value in LoopError event to null (Nothing in VB), then GetFiles operation will continue (ignoring the error) normally.
Do not forget that RemotePath should always specify full absolute path (i.e. /home/joe/something) instead of relative path (i.e. joe/something). LocalPath should also specify full path (i.e. C:\home\joe\something) instead of relative path (i.e. joe\something).