EFCreateError

Delphi Programming Language

Severity: Minor

What it means

The message names the file: Cannot create file, followed by its path in quotes.
Embarcadero: EFCreateError is raised when an application unsuccessfully attempts to create a file. For example, the file name is invalid, or a file by that name exists and can't be overwritten, because the user lacks access permission.
It usually comes from TFileStream.Create with fmCreate, or from a SaveToFile method.

Affected Models

  • Delphi programs at run time

How to Fix It

  1. Read the path in the message. Empty, as in Cannot create file ""? Then the code passed no file name at all. Check the variable that holds it.

  2. Check the folder exists. Creating a file doesn't create the folders above it. ForceDirectories(ExtractFilePath(FileName)) makes them first.

  3. Check your program may write there. Windows protects folders such as Program Files. Save to the user's own folders instead, such as the one TPath.GetDocumentsPath returns, from System.IOUtils.

  4. The file exists already? It may be read-only, or open in another program. Clear the read-only attribute, or close the other program.