Compartilhar via


DOWNLOADFROMSTREAM Function (File)

Sends a file from Microsoft Dynamics NAV Server computer to the client computer. The client computer is the computer that is running the Microsoft Dynamics NAV Windows client or the computer that is running the browser that accesses the Microsoft Dynamics NAV Web client or Microsoft Dynamics NAV SharePoint client.

[Ok :=] DOWNLOADFROMSTREAM(VarInstream, DialogTitle, ToFolder, ToFilter, ToFile)

Parameters

  • VarInStream
    Type: Variant An InStream that you want to use to send the data in a file on Microsoft Dynamics NAV Server to a file on the client computer.
  • DialogTitle
    Type: Text The title that you want to display in the dialog box for downloading the file.

    Note

    This parameter is not supported by the Microsoft Dynamics NAV Web client or Microsoft Dynamics NAV SharePoint 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.

    Note

    This parameter is not supported by the Microsoft Dynamics NAV Web client or Microsoft Dynamics NAV SharePoint client. By default, 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.

    Note

    This parameter is not supported by the Microsoft Dynamics NAV Web client or Microsoft Dynamics NAV SharePoint client.

  • ToFile
    Type: Variant 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.

Property Value/Return Value

Type: Boolean

If you omit this optional return value, then a run-time error occurs if the record cannot be found. If you include a return value, then you must handle any errors.

true if the file was downloaded; otherwise, false.

Remarks

Note

This function is not fully supported by the Microsoft Dynamics NAV Web client 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 that supports the file type.

The business logic runs on the computer that is running Microsoft Dynamics NAV Server and not on the client. Files are created on a Microsoft Dynamics NAV service and not locally on the client computer. When you write code, you must consider where files are created.

Use UPLOAD Function (File) and UPLOADINTOSTREAM Function (File) to send a file from a client to a Microsoft Dynamics NAV Server instance.

Use DOWNLOAD Function (File) and DOWNLOADFROMSTREAM Function (File) to send a file from a Microsoft Dynamics NAV Server instance to a client.

We recommend that you use the functions in codeunit 419, 3-Tier Automation Mgt., to upload and download files.

Example

This example requires that you create the following variables.

Name DataType

TempFile

File

NewStream

InStream

ToFileName

Variant

TempFile.CREATETEMPFILE();
TempFile.WRITE('abc');
TempFile.CREATEINSTREAM(NewStream);
ToFileName := 'SampleFile.txt';
DOWNLOADFROMSTREAM(NewStream,'Export','','All Files (*.*)|*.*',ToFileName)

See Also

Tasks

Walkthrough: Transferring a File from Microsoft Dynamics NAV Server to the Client

Reference

File Data Type