Skip to content

Latest commit

 

History

History
94 lines (68 loc) · 4.55 KB

File metadata and controls

94 lines (68 loc) · 4.55 KB
title description ms.author ms.date ms.topic author ms.reviewer
File.Download(Text, Text, Text, Text, var Text) Method
Sends a file from a server computer to the client computer.
solsen
05/14/2024
reference
SusanneWindfeldPedersen
solsen

File.Download(Text, Text, Text, Text, var Text) Method

Version: Available or changed with runtime version 1.0.

Sends 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.

Note

This method is supported only in Business Central on-premises.

Syntax

[Ok := ]  File.Download(FromFile: Text, DialogTitle: Text, ToFolder: Text, ToFilter: Text, var ToFile: Text)

Note

This method can be invoked without specifying the data type name.

Parameters

FromFile
 Type: Text
The name of the file on the server computer that you want to download to the client computer.

DialogTitle
 Type: Text
The 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.

ToFolder
 Type: Text
The 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.

ToFilter
 Type: Text
The 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.

ToFile
 Type: Text
The 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.

Return Value

[Optional] Ok
 Type: Boolean
true 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.

Remarks

Note

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.

Files are saved to the default download location that is configured in the end-user's browser.

The business logic is run on the computer that is running [!INCLUDEd365fin_server_md] and not on the client. Files are created on the computer that is running [!INCLUDEd365fin_server_md] and not locally on the client computer.

Upload Method (File) and UploadIntoStream Method (File) are used to send a file from the client to a [!INCLUDEd365fin_server_md] instance.

Download Method (File) and DownloadFromStream Method (File) are used to send a file from a [!INCLUDEd365fin_server_md] instance to the client.

We recommend that you use the methods in codeunit 419 File Management to upload and download files.

[!INCLUDEmulti_file_download_web_client]

Example

This example shows how to use the Download method.

 var
    ToFile: Text;
begin
    ToFile := 'ToFile.txt';  
    Download('FromFile.txt','Download file','C:\','Text file(*.txt)|*.txt',ToFile);  
end;

See Also

File Data Type
Get Started with AL
Developing Extensions