Description
-
Fires during file transfer, allowing you to alter file contents.
Syntax
-
Private Sub
object_FileTransferData(FileData())
The FileTransferData Event syntax has these parts:
| object |
A wodFtpDLX
object. |
| FileData |
An array of Byte values.
Actual data as byte array (SAFEARRAY(unsigned char *) for VC++
users). |
Remarks
-
FileTransferData event is fired during file transfers when
LocalPath property (and LocalPath argument in GetFile or PutFile
methods) isn't set, or is set to "" (empty string). In such cases,
GetFile and
PutFile methods
will not open local file for reading/writing, instead they will fire
this event allowing you to read/write data from remote file
from/to byte array.
Since FileData argument is a byte array, file contents can be
changed in size and in values - you can supply new byte array to
this argument if needed. For example, following code will always
destroy all values in the array, and no matter how large files user
tries to upload (or download), it will always end up with zero sized
file:
- Private Sub
FtpDLX1_FileTransferData(FileData() As Byte)
Dim b() As Byte
DirData = b
End Sub
-
-
For downloads: In order to determine exactly how many
bytes are in FileData array, you should calculate it like this (VB
example):
- UBound(FileData) - LBound(FileData) +
1
-
-
Remember that FileData(0) is the first element in the array.
-
-
For uploads: to create new byte array and put some data
inside, so it is transferred to remote side, you can use code
similar to this (VB example):
- Private Sub
Ftp1_FileTransferData(FileData() As Byte)
Dim a As String
a = "some text"
ReDim FileData(Len(a) - 1)
Dim i As Integer
For i = 0 To Len(a) - 1
FileData(i) = Asc(Mid$(a, i + 1, 1))
Next i
Exit Sub
|