Technical Note 1101
Last Reviewed 05-Mar-2014
Reflection FTP Client version 14.0 or higher
Reflection for Secure IT Windows Client version 7.0 or higher
This technical note describes how to use the Reflection FTP Type Libraries, which provide a COM API to automate secure file transfers. Code samples in C# and VBA are provided.
Reflection FTP Client is included in many Attachmate products, including the following:
INFOConnect Enterprise Edition version 8.0 or higher
Reflection for HP
Reflection for IBM
Reflection for UNIX and OpenVMS
Note: For information about automating SFTP file transfers using Reflection for Secure IT command line utilities, see Technical Note 2126.
SFTP transfers can also be automated using a recorded script. For information about using an FTP Client script see Technical Note 1308.
Establish an Authentication Method that Can be Automated
To automate file transfers, Attachmate Technical Support recommends first setting up an authentication method that does not require user input, such as Public Key Authentication with an empty passphrase. It is possible to send a password in your program; however, the security risk is greater when plain text passwords are saved in source code.
For detailed steps on configuring Reflection for public key authentication, see Technical Note 1881.
Reflection FTP Type Libraries
Reflection FTP 1.15 Type Library (RFTPCOM15.DLL) is included with Reflection next generation emulation productsReflection 2014 and Reflection 2011.
Reflection FTP 1.0 Type Library (RFTPCOM.DLL) is included with Reflection FTP Client 14.x, Reflection for Secure IT 7.x, EXTRA! 9.x, and INFOConnect Enterprise Edition 8.x.
To add a reference to Reflection FTP:
In a .NET project in Microsoft Visual Studio 2005 2010, go to Project > Add Reference.
Choose the COM tab and scroll to the FTP type library appropriate to your installation.
In Visual Basic for Applications, go to Tools > References.
Note: If you see both Reflection FTP 1.15 and 1.0 Type Libraries, you may have installed two incompatible versions of Attachmate products. One will need to be uninstalled before you can use the Reflection FTP API.
This example uses Reflection FTP 1.15 Type Library and works with Reflection 2014 and 2011. A variable is used to create a filter for file extensions. The application will transfer all files in a given directory that match the strFilter variable.
To see the .NET example:
- Download SFTP_ConsoleApp.cs.txt from the Attachmate Download Library.
- In Visual Studio, create a new C# console application.
- Replace all the code in Program.cs with the text of SFTP_ConsoleApp.cs.txt.
- Edit the code to put in the hostname and username of your SFTP server.
- Edit the following variables to fit your environment:
strHostPath, strLocalPath, strFilter, and strLogFile.
- Run or step into the code.
This example uses Reflection FTP 1.0 Type Library and works with Reflection FTP 14.x and Reflection for Secure IT. VBA is used to create a filter for file extensions. The macro will transfer all files in a given directory that match the strFilter variable.
- Download SecureFTP.bas, and import it to a VB or VBA editor.
- In your VB or VBA editor, add a reference to Reflection FTP 1.0 Type Library
- In the editor, click File > Import; then import SecureFTP.bas.
Using Reflection FTP Automation API, you can add features to your programs, such as checking to see if files exist before attempting a transfer, deleting files when you are done, writing error logs, or emailing system administrators when a critical file transfer fails.