I have been working on a solution for file download.  I am now able to download both binary and text files both via http and ftp and both with Classic Client and Role Tailored Client.

Attached is a codeunit that can download a text file via http, a zip file via http and a text file via ftp.  I use dotnet object for the Role Tailored Client to handle files on the client side.

FileDownload

4 thoughts on “File Download via HTTP and FTP

  1. eernst says:

    Hi Gunnar,
    Very nice little tool. Works fine, files are imported. But I’m having issues with the text encoding. The file I’m downloading is a CSV file in Windows format.
    And it contains some of the danish ÆØÅ characters.

    After the import, I’m calling an XMLport to read the data, directly from the blob field. It had no effect to add the Windows encoding here.
    I then tried to save the actual data to a file, using FILE.WRITE(HTTPRequest.responseText); and here I can see that the data are “messed” up already before they get into NAV.
    Any suggestions?
    /Erik

    1. Look at my blog entry about reading and writing text files. There you can see how to use encoding.

  2. Rishi Chourey says:

    Hi Gunnar,

    I was trying to use your DownloadFTPFile function to download text file from FTP server.
    I have a confustion regarding this TempFileName variable and because of this it is giving me following error. Please guide me.
    —————————
    Microsoft Dynamics NAV Classic
    —————————
    The operating system cannot find the file D:\Users\T14239\AppData\Local\Tempnrdata.txt .

    Verify that the drive, directory, and file names are correct.

    —————————
    OK
    —————————

Leave a Reply

%d bloggers like this: