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

2 Comments

  1. Hi,

    I am facing the below issue while running the code. Please provide some solution.

    Thank you.

    Microsoft Dynamics NAV
    —————————

    A call to FTPS_For_Nav_DLL.FTPS failed with this message: Request for the permission of type ‘System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.

    • Hello and sorry for the response time.
      I hope you resolve your problem on your own since elsewere it seem to be a file permission problem on location you provide to the upload or download function.
      You can try a Nav RENAME function to the same file location (after a save) to check if you got the same kind of error.

Leave a Reply

Your email address will not be published. Required fields are marked *