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?
LoopItemEvent event
Fires before wodSFTP.NET performs operation on file from the GetFiles/PutFiles/DeleteFiles/LoopFiles sequence.
Syntax
- C#
- VB.NET
delegate void LoopDelegate(object Sender, LoopArgs Args);
The LoopItemEvent(Args.Error,Args.ItemType,Args.LocalFile,Args.RemoteFile,Args.Skip) syntax has these parts:
The LoopItemEvent(Args.Error,Args.ItemType,Args.LocalFile,Args.RemoteFile,Args.Skip) syntax has these parts:
Args.Error | Exception. Exception information about the error, if error occurred. |
Args.ItemType | DirItemTypes enumeration value. Type of the item - file, folder, symbolic link. |
Args.LocalFile | String. Full path to file/folder on local disk. |
Args.RemoteFile | String. Full path to file/folder on remote server. |
Args.Skip | Boolean. When set to True then intended operation is not performed on the item. |
Delegate Sub LoopDelegate(ByVal Sender As Object, ByVal Args As WeOnlyDo.Client.SFTP.LoopArgs)
The LoopItemEvent(Args.Error,Args.ItemType,Args.LocalFile,Args.RemoteFile,Args.Skip) syntax has these parts:
The LoopItemEvent(Args.Error,Args.ItemType,Args.LocalFile,Args.RemoteFile,Args.Skip) syntax has these parts:
Args.Error | Exception. Exception information about the error, if error occurred. |
Args.ItemType | DirItemTypes enumeration value. Type of the item - file, folder, symbolic link. |
Args.LocalFile | String. Full path to file/folder on local disk. |
Args.RemoteFile | String. Full path to file/folder on remote server. |
Args.Skip | Boolean. When set to True then intended operation is not performed on the item. |
Remarks
This event fires as result of GetFiles, DeleteFiles, PutFiles and LoopFiles methods. It provides information about each item in the sequence (meaning file or folder) before actual operation on that item is executed - allowing you to optionally Skip the operation for this particular item.Since both LocalFile and RemoteFile arguments can be changed, you can also cause operation to be performed on completely different files than it would be in original operation.
For example, you can use LoopItem event like this:
private void sftp1_LoopItemEvent(object Sender, WeOnlyDo.Client.SFTP.LoopArgs Args)
{
if (Args.ItemType == WeOnlyDo.Client.SFTP.DirItemTypes.Directory)
Args.Skip = false;
else
if (Args.LocalFile.EndsWith(".txt"))
Args.Skip = false;
else
Args.Skip = true;
}
which means that only files ending with ".txt" are copied - others are skipped (but directories are created, just in case).
You can also use it like this: we will copy all ".txt" files to the same directory, no matter where they originate from:
private void sftp1_LoopItemEvent(object Sender, WeOnlyDo.Client.SFTP.LoopArgs Args)
{
if (Args.LocalFile.EndsWith(".txt"))
{
Args.LocalFile = @"c:\mytxtfiles\file" + mycounter.ToString();
mycounter++;
Args.Skip = false;
}
else
Args.Skip = true;
}
above sample will not create directory structure at all - but still would copy all .txt files to differently named files on local disk.