PutData Method  
 

Transfers data from a local buffer and stores it in a file on the server.

Syntax

object.PutData( RemoteFile, Buffer, [Length], [Reserved] )

Parameters

RemoteFile
A string that specifies the file on the server that will contain the data being transferred. If the file already exists, it will be overwritten. The file pathing and name conventions must be that of the server.
Buffer
This parameter specifies the local buffer that the data will be copied from. If the parameter is a String type, then the data will be written as a string of characters. For binary data, it is recommended that this parameter specify a Byte array.
Length
An optional integer argument that specifies the amount of data to be copied from the buffer. If this argument is omitted, the entire contents of the buffer is transferred to the server.
Reserved
An argument reserved for future expansion. This argument should always be omitted or specified as a numeric value of zero.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Remarks

The PutData method transfers data from a local buffer and stores it on a file on the server. This method will cause the current thread to block until the file transfer completes, a timeout occurs or the transfer is canceled. During the transfer, the OnProgress event will fire periodically, enabling the application to update any user interface objects such as a progress bar.

If the Buffer parameter is a String type, this method presumes that it only contains text and will automatically convert it from its native Unicode to ASCII. If the string contains binary data, this process can corrupt the data and therefore should never be used. To prevent this conversion and upload Unicode text to the server, you should convert the string to a byte array using the StrConv function and set the FileType property to ftpFileTypeBinary.

See Also

BufferSize Property, Priority Property, GetData Method, GetFile Method, PutFile Method, OnProgress Event