Ftp Interface
The Ftp object (IFtp) is returned by the CreateFtp function that is provided through the ComScript connection interface. Through this object, FTP functionality can be used in programs that are written in any COM supporting development environment.
The following functionality is provided:
Properties
Name | Return type | Access | Description |
BufferSize | Integer | Read/Write | The buffer size for reading or writing to a stream, default is 2048. |
EnableSsl | Boolean | Read/Write | Set to true to enable SSL/TLS for the connection, default is false. |
ErrorCode | Integer | Read only | The error code for the current error. |
ErrorDescription | String | Read only | The error description for the current error. |
HostName | String | Read/Write | FTP hostname. |
Password | String | Read/Write | FTP Login password. |
ReadWriteTimeout | Integer | Read/Write | The time-out in milliseconds when reading or writing to a stream, default is 300000 milliseconds (5 minutes). |
Timeout | Integer | Read/Write | The number of milliseconds to wait for a request, default is infinite. |
UseBinary | Boolean | Read/Write | When set to true, files will be transferred in Binary mode. When set to false, files will be transferred in ASCII mode. Default is true (Binary). |
UsePassive | Boolean | Read/Write | When set to true, the FTP will run in Passive mode. When set to false, the FTP will run in Active mode. Default is true (Passive). |
UserName | String | Read/Write | FTP Login username. |
Functions
function name | Return type | Parameters | Description | |
Name | Type | |||
AppendFile | Boolean | RemoteFile | String | Append a file to an existing file on an FTP server. |
LocalFile | String | |||
DeleteFile | Boolean | RemoteFile | String | Delete a file on an FTP server. |
DownloadFile | Boolean | RemoteFile | String | Download a file from an FTP server. |
LocalFile | String | |||
GetDateTimestamp | DateTime | RemoteFile | String | Retrieve the date-time stamp from a file on an FTP server. |
GetFileSize | Integer | RemoteFile | String | Retrieve the size of a file on an FTP server. |
ListDirectory | String Array |
RemoteDirectory | String | Retrieve a short listing of the files on an FTP server. Includes the directory path. |
ListDirectoryDetails | String Array |
RemoteDirectory | String | Retrieve a detailed listing of the files on an FTP server. Includes the directory path. |
MakeDirectory | Boolean | NewRemoteDirectory | String | Create a directory on an FTP server. |
RemoveDirectory | Boolean | RemoteDirectory | String | Removes a directory on an FTP server. |
Rename | Boolean | RemoteFile | String | Rename a file or directory on an FTP server. |
NewRemoteFile | String | |||
UploadFile | Boolean | RemoteFile | String | Upload a file on an FTP server. |
LocalFile | String |
Example
PowerShell
#See ComScript Connection Interface
...
$ComScr.Connect()
#Create an object of the AmtFtp Interface to be able to transfer files.
$AmtFtp = $ComScr.CreateFtp()
#Fill in all the information for the server
$AmtFtp.Hostname = "Localhost"
$AmtFtp.Username = "TestUser"
$AmtFtp.Password = "TestPass"
#Download a file from the FTP Server
$Success = $AmtFtp.DownloadFile("/TEST/HelloWorld.txt", "D:\HelloWorld.txt")
if ($Success) {
Write-Host "File Successfully Downloaded!"
} else {
Throw ("FTP Downloadfile Failed: $($AmtFtp.Errordescription)")
}
# Finally release the variables and clean up the session.
$ComScr.Dispose()