Using FTP over SSL/TLS (FTPS) in Business Central

I’ve made a .Net lib to access FTP over SSL/TLS functions from Nav/Business Central on Premise. It’s bases on limilabs Ftp.dll. This one is accepting all security certificate including self-signed. Do not confuse with SFTP that is FTP encapsulated in SSH.

Download it here : FTPS-For-Nav.zip

Install thoses two DLLs in service and roletailored client addin folders of Nav installation. Then you can use this function in C/AL. Exemple below, declare a variable DotNet of type “FTPS_For_Nav_DLL.FTPS”.

// Instanciate
DotNLFTPS := DotNLFTPS.FTPS();

// Login
DotNLFTPS.Connect('localhost', 'me', 'mypassword');

// Download
TxtLError := DotNLFTPS.DownloadFile('ftpfolder\test.txt', 'D:\test.txt');
IF TxtLError <> '' THEN
  MESSAGE('Download failed with error: ' + TxtLError)
ELSE
  MESSAGE('Download sucess !');

// Upload
TxtLError := DotNLFTPS.UploadFile('D:\test.txt', 'ftpfolder\test2.txt');
IF TxtLError <> '' THEN
  MESSAGE('Upload failed with error: ' + TxtLError)
ELSE
  MESSAGE('Upload sucess !');

// Delete
DotNLFTPS.Deletefile('ftpfolder\test.txt');

// List root files
DotNLFTPS.ListFiles('ftpfolder');

// Loop through files
REPEAT
  TxtLFile := DotNLFTPS.GetNextFile();
  IF TxtLFile <> '' THEN
    TxtLFileList += TxtLFile + '\';
UNTIL TxtLFile = '';

// Close
DotNLFTPS.Disconnect();

MESSAGE(TxtLFileList); // show file list

Leave a Reply

Your e-mail address will not be published. Required fields are marked *