FTP Transfer all files in Directory

Hi All, I am working on a project where I have a lot of CSV files in three directories that I would like to periodically transfer to an FTP server.

I have successfully initiated a connection and was able to send a file to the server from my PFC300 controller with the WagoAppFTP.FbFTP.FileWrite function. I now am working on code to automate the transfer of all the contents of the specified directory where the CSV files are stored on the controller to the server.

I am sure there is a better way to do this but for now my thought was to use the WagoAppFileDir.FbDirectoryReader_cpt function to gather the full filename including path. My understanding is that with each entry that is read, the xTrigger INOUT goes FALSE and at that point I can take the file name to create a complete path to the file and feed that into the WagoAppFTP.FbFTP.FileWrite function to transfer. Then I can trigger the xTrigger once again to repeat the process until the function is finished (xEofReached goes True). I am in the process of writing the code to do this so I am not sure if I truly understood how the directory reader function works from the documentation.

One issue is that I potentially could have almost 5,000 files to transfer in the worst case. While I want to support that many files, I am strongly discouraging users to allow so many files to be on the SD card of the controller since it will of course take a long time to transfer that many files.

Is there a better way to do this? Is there a recommended best practice for handling automation of FTP of files?

If you can try to limit the maximum number of files in one folder.
I have the habit to crate a folder structure which will limit my number of files, with this the scan and files access is faster and easier to use.

1 Like

Maybe zip the folder before sending.

1 Like