$ Functions: Devices - FTP

$Devices.FTPClientDevice.AppendText(filePath, text : String)
Arguments
  • filepath: String, specifying the path and filename of the text file to append.
  • text: String, specifying the text to write.
Returns

N/A

Description

Appends text to the end of the file (specified by the filePath argument) on the FTP server.

Note: If the file does not exist, then the specified file and any preceding directories will be created on the remote server.

 

$Devices.FTPClientDevice.DeleteDirectory(dirPath : String)
Arguments dirPath: String, specifying the path of the directory to delete.
Returns

N/A

Description

Deletes the directory specified by the dirPath argument and all its contents on the FTP server.

 

$Devices.FTPClientDevice.DeleteFile(filePath : String)
Arguments filePath: String, specifying the path of the file to delete.
Returns

N/A

Description

Deletes the remote file specified with the filePath argument.

 

$Devices.FTPClientDevice.DirectoryExists(dirPath : String) : Boolean
Arguments dirPath: String, specifying the path of the directory to check.
Returns

Boolean, indicating whether the specified directory exists or not.

Description

Checks if the directory specified by the dirPath argument exists on the FTP server.

 

$Devices.FTPClientDevice.FileExists(filePath : String) : Boolean
Arguments filePath: String, specifying the path of the file to check.
Returns

Boolean, indicating whether the specified file exists or not.

Description

Checks if the file specified by the filePath argument exists on the FTP server.

 

$Devices.FTPClientDevice.ReadText(filePath : String) : String
Arguments filePath: String, specifying the path of the file to read.
Returns

The contents of the specified file as a string.

Description

Reads the content of the file (specified by the filePath argument) on the FTP server.

Note: Reading of remote files is restricted to 5 MB.

 

$Devices.FTPClientDevice.Reconfigure(newConfiguration : Dictionary)
Arguments

newConfiguration: A configuration object of Dictionary <string, object> type, containing the new FTP configurations to set as property name-value pairs.

Returns N/A
Description

This function is used to reconfigure the connection configuration of an FTP client device. See the below example on how to apply a new FTPClientDevice configuration:

var newConfiguration = new Dictionary<string, object>();
  newConfiguration.Add("RemoteAddress", "192.168.1.84");
  newConfiguration.Add("PortNumber", 22);
  newConfiguration.Add("UserName", "NewUser");
$Devices.[FTPClientDevice].Reconfigure(newConfiguration);
Note:
  • You can also configure an FTP Client Device with the Cognex Designer user interface.
  • This function disconnects the FTP Client Device, sets the new connection configuration, and then attempts to reconnect using the new configuration.

 

$Devices.FTPClientDevice.WriteText(filePath, text : String)
Returns

N/A

Arguments
  • filePath: String, specifying the path and the filename of the text file to write to.
  • text: String, specifying the text to write.
Description

Writes text to the file (specified by the filePath argument) on the FTP server.

Note:
  • If the specified file already exists, it will be overwritten.
  • If the file does not exist, then the specified file and any preceding directories will be created on the remote server.