Creates and opens an ASCII or binary file. If the file already exists, it will be truncated and then opened.

[Ok := ] File.CREATE(Name)



Type: FileSpecifies the file to create.

Type: Text or codeThe name of the file that include the path. The following rules apply:
  • 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.

Property Value/Return Value

Type: Boolean

Specifies whether the file was created.

true if the file was created; otherwise, false.


If the TEXTMODE Function (File) returns true and you read or write to the file, text is put in the buffer.

If the TEXTMODE Function (File) function returns false, binary information is put in the buffer.

If you call CREATE on a File variable that refers to an open file, the function does not automatically close the existing file and create the new file. You must explicitly call the CLOSE Function (File) to close the existing file. Otherwise, a run-time error occurs.


The following example creates a file that is named TestFile.txt in the path C:\TestFolder\ .The TestFile variable stores the file and path that is created. If the file is created, a message that states that the file is created is displayed. Otherwise, an error message is displayed. This example requires that you create the following variable in the C/AL Globals window.

Variable name DataType



  Copy Code
IF TestFile.CREATE('C:\TestFolder\TestFile.txt') THEN BEGIN
  MESSAGE('%1 is created', TestFile.NAME)
ERROR('The file could not be created');

See Also


File Data Type