{"title":"File.Download(Text, Text, Text, Text, var Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/file/file-download-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/file/file-download-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/file/file-download-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Sends a file from a server computer to the client computer.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"File.Download(Text, Text, Text, Text, var Text) Method","slug":"filedownloadtext-text-text-text-var-text-method","at":0,"chars":4080},{"level":2,"title":"Syntax","slug":"syntax","at":392,"chars":204},{"level":2,"title":"Parameters","slug":"parameters","at":596,"chars":1163},{"level":2,"title":"Return Value","slug":"return-value","at":1759,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":1997,"chars":1733},{"level":2,"title":"Example","slug":"example","at":3730,"chars":218},{"level":2,"title":"Related information","slug":"related-information","at":3948,"chars":132}],"text":"# File.Download(Text, Text, Text, Text, var Text) Method\n> Version: _Available or changed with runtime version 1.0._\nSends a file from a server computer to the client computer. The client computer is the computer that is running the Windows client or the computer that is running a browser that accesses the web client.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n[Ok := ]  File.Download(FromFile: Text, DialogTitle: Text, ToFolder: Text, ToFilter: Text, var ToFile: Text)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nFromFile\nType: ../text/text-data-type\nThe name of the file on the server computer that you want to download to the client computer.\nDialogTitle\nType: ../text/text-data-type\nThe title that you want to display in the dialog box for downloading the file. This parameter is not supported by the web client. The title is determined by the end-user's browser.\nToFolder\nType: ../text/text-data-type\nThe default folder in which to save the file to be downloaded. The folder name is displayed in the dialog box for downloading the file. The folder can be changed by the user. This parameter is not supported by the web client. By default, the files are saved to the default download location that is configured in the end-user's browser.\nToFilter\nType: ../text/text-data-type\nThe type of file that can be downloaded to the client computer. The type is displayed in the dialog box for downloading the file. This parameter is not supported by the web client.\nToFile\nType: ../text/text-data-type\nThe name to give the downloaded file. This is the default file name that is shown in the dialog box for downloading the file. This value can be changed by the user.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.\n## Remarks\n> NOTE\n> On devices that run Apple iOS, such as iPad, you can only download a file if the Apple iOS device on which you are downloading the file has an application which supports the file type.\nFiles are saved to the default download location that is configured in the end-user's browser.\nThe business logic is run on the computer that is running Dynamics 365 Business Central service and not on the client. Files are created on the computer that is running Dynamics 365 Business Central service and not locally on the client computer.\nfile-upload-method and file-uploadintostream-string-string-string-text-instream-method are used to send a file from the client to a Dynamics 365 Business Central service instance.\nfile-download-method and file-downloadfromstream-method are used to send a file from a Dynamics 365 Business Central service instance to the client.\nWe recommend that you use the methods in codeunit 419 File Management to upload and download files.\n> NOTE\n> Internet browsers can only handle one file per request. Therefore, with the Web client, if this method is called in a repetitive statement (or loop) that generates multiple files, only the last file will be sent to the browser. Alternatively, when designing for the Web client, bundle the files in an archive file (.zip), for example, by using the methods found in codeunit 419 File Management. For more details about this design pattern, see Multi-File Download<https://alguidelines.dev/docs/navpatterns/patterns/multi-file-download/>. The methods in codeunit 419 aren't external, therefore can't be used in extensions. Instead, when developing extensions in AL, use the external methods of codeunit 425 Data Compression. The approach is similar.\n## Example\nThis example shows how to use the Download method.\n```al\n var\n    ToFile: Text;\nbegin\n    ToFile := 'ToFile.txt';\n    Download('FromFile.txt','Download file','C:\\','Text file(*.txt)|*.txt',ToFile);\nend;\n```\n## Related information\nfile-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}