File.Erase(Text) Method

Version: Available or changed with runtime version 1.0.

Deletes a file.

Note

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

Syntax

[Ok := ]  File.Erase(Name: Text)

Note

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

Parameters

Name
 Type: Text
The name of the file that you want to delete, including the path. When you enter the path, consider these shortcuts:

  • You can omit the drive designation if the file is located on the current drive.
  • You can omit the full path if the file is located in the current directory.
  • You can enter only the subdirectory name if the file is located in a subdirectory of the current directory.

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.

If the user who runs this method does not have the required permission to delete the file or if the file is read-only, then the file is not deleted.

Example

The following example deletes the file that is named C:\TestFolder\NewTestFile.txt.This example assumes that you have created the file on your computer.

Erase('C:\TestFolder\NewTestFile.txt');  

File Data Type
Get Started with AL
Developing Extensions