Codeunit "External File Storage"
Methods
Initialize
Initializes the File Storage for the given scenario.
procedure Initialize(Scenario: Enum "File Scenario")
Parameters
| Name | Type | Description |
|---|---|---|
| Scenario | Enum System.ExternalFileStorage."File Scenario" |
File Scenario to use. |
Initialize
Initializes the File Storage for the give file account.
procedure Initialize(TempFileAccount: Record "File Account" temporary)
Parameters
| Name | Type | Description |
|---|---|---|
| TempFileAccount | Table System.ExternalFileStorage."File Account" |
File Account to use. |
ListFiles
List all files from the given path.
procedure ListFiles(Path: Text, FilePaginationData: Codeunit "File Pagination Data", var TempFileAccountContent: Record "File Account Content" temporary)
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Folder to list |
| FilePaginationData | Codeunit System.ExternalFileStorage."File Pagination Data" |
Defines the pagination data. |
| TempFileAccountContent | Table System.ExternalFileStorage."File Account Content" |
File account content. |
GetFile
Retrieves a file from the file account.
[TryFunction]
procedure GetFile(Path: Text, Stream: InStream): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
File Path to open. |
| Stream | InStream |
Stream which contains the file content. |
Returns
| Type | Description |
|---|---|
| Boolean |
CreateFile
Stores a file in to the file account.
[TryFunction]
procedure CreateFile(Path: Text, Stream: InStream): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
File Path inside the file account. |
| Stream | InStream |
Stream to store. |
Returns
| Type | Description |
|---|---|
| Boolean |
CopyFile
Copies a file in the file account.
[TryFunction]
procedure CopyFile(SourcePath: Text, TargetPath: Text): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| SourcePath | Text |
Source path of the file. |
| TargetPath | Text |
Target Path of the file copy. |
Returns
| Type | Description |
|---|---|
| Boolean |
MoveFile
Moves a file in the file account.
[TryFunction]
procedure MoveFile(SourcePath: Text, TargetPath: Text): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| SourcePath | Text |
Source path of the file. |
| TargetPath | Text |
Target Path of the file. |
Returns
| Type | Description |
|---|---|
| Boolean |
FileExists
Checks if a specific file exists in the file account.
procedure FileExists(Path: Text): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
File path to check. |
Returns
| Type | Description |
|---|---|
| Boolean |
Returns true if the file exists. |
DeleteFile
Deletes a file from the file account.
[TryFunction]
procedure DeleteFile(Path: Text): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
File path of the file to delete. |
Returns
| Type | Description |
|---|---|
| Boolean |
ListDirectories
List all directories from the given path.
[TryFunction]
procedure ListDirectories(Path: Text, FilePaginationData: Codeunit "File Pagination Data", var TempFileAccountContent: Record "File Account Content" temporary): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Folder to list |
| FilePaginationData | Codeunit System.ExternalFileStorage."File Pagination Data" |
Defines the pagination data. |
| TempFileAccountContent | Table System.ExternalFileStorage."File Account Content" |
Folder to list |
Returns
| Type | Description |
|---|---|
| Boolean |
CreateDirectory
Creates a directory in the file account.
[TryFunction]
procedure CreateDirectory(Path: Text): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Path of the new Directory to create. |
Returns
| Type | Description |
|---|---|
| Boolean |
DirectoryExists
Checks if a specific directory exists in the file account.
procedure DirectoryExists(Path: Text): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Path of the directory to check. |
Returns
| Type | Description |
|---|---|
| Boolean |
Returns true if directory exists. |
DeleteDirectory
Deletes a directory from the file account.
[TryFunction]
procedure DeleteDirectory(Path: Text): Boolean
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Directory to remove. |
Returns
| Type | Description |
|---|---|
| Boolean |
CombinePath
Combines to paths together.
procedure CombinePath(Path: Text, ChildPath: Text): Text
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
First part to combine. |
| ChildPath | Text |
Second part to combine. |
Returns
| Type | Description |
|---|---|
| Text |
Correctly combined path. |
GetParentPath
Gets the Parent Path of the given path.
procedure GetParentPath(Path: Text): Text
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
File or directory path. |
Returns
| Type | Description |
|---|---|
| Text |
The parent of the specified path. |
SelectAndGetFolderPath
Opens a folder selection dialog.
procedure SelectAndGetFolderPath(Path: Text): Text
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Start path of the dialog. |
Returns
| Type | Description |
|---|---|
| Text |
Returns the selected Folder. |
SelectAndGetFolderPath
Opens a folder selection dialog.
procedure SelectAndGetFolderPath(Path: Text, DialogTitle: Text): Text
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Start path of the dialog. |
| DialogTitle | Text |
Title of the selection dialog. |
Returns
| Type | Description |
|---|---|
| Text |
Returns the selected Folder. |
SelectAndGetFilePath
Opens a select file dialog.
procedure SelectAndGetFilePath(Path: Text, FileFilter: Text): Text
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Start path. |
| FileFilter | Text |
A filter string that applies only on files not on folders. |
Returns
| Type | Description |
|---|---|
| Text |
Returns the path of the selected file. |
SelectAndGetFilePath
Opens a select file dialog.
procedure SelectAndGetFilePath(Path: Text, FileFilter: Text, DialogTitle: Text): Text
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Start path of the dialog. |
| FileFilter | Text |
A filter string that applies only on files not on folders. |
| DialogTitle | Text |
Title of the selection dialog. |
Returns
| Type | Description |
|---|---|
| Text |
Returns the path of the selected file. |
SaveFile
Opens a save to dialog.
procedure SaveFile(Path: Text, FileExtension: Text): Text
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Start path of the dialog. |
| FileExtension | Text |
The file extension without dot (like pdf or txt). |
Returns
| Type | Description |
|---|---|
| Text |
Returns the selected file path. |
SaveFile
Opens a save to dialog.
procedure SaveFile(Path: Text, FileExtension: Text, DialogTitle: Text): Text
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Start path of the dialog. |
| FileExtension | Text |
The file extension without dot (like pdf or txt). |
| DialogTitle | Text |
Title of the selection dialog. |
Returns
| Type | Description |
|---|---|
| Text |
Returns the selected file path. |
SaveFile
Opens a save to dialog.
procedure SaveFile(Path: Text, FileNameSuggestion: Text, FileExtension: Text, DialogTitle: Text): Text
Parameters
| Name | Type | Description |
|---|---|---|
| Path | Text |
Start path of the dialog. |
| FileNameSuggestion | Text |
Suggested file name for the dialog. |
| FileExtension | Text |
The file extension without dot (like pdf or txt). |
| DialogTitle | Text |
Title of the selection dialog. |
Returns
| Type | Description |
|---|---|
| Text |
Returns the selected file path. |
BrowseAccount
Opens a File Browser
procedure BrowseAccount()