[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Dialogs' (#lcl)

# TOpenDialog.CheckFile

Ensures the specified file name meets the requirements for the dialog.

## Declaration

Source position: dialogs.pp line 249

`protected function TOpenDialog.CheckFile(`
`var AFilename: string`
`):Boolean; virtual;`

## Arguments

`AFilename` |  | Fully-qualified file name or directory path examined and possibly updated in the method.

## Function result

True if the file name is valid for the open dialog.

## Description

CheckFile is a Boolean function used to examine and update the specified file name. AFilename is a variable argument which contains the path to the file and can include its extension. The return value is True if the file name satisfies the filter, extension, and options used for the open dialog.

Values in DefaultExt, Filter, and FilterIndex are used to get a file extension when AFilename does not already include one. The file extension is appended to the value in AFilename.

Values in Options are used to determine if the file name is usable, including:

ofPathMustExist
  The path in AFilename must already exist on the local file system. If it does not exist, a rsfdPathNoExist message is displayed and the method is exited.
ofFileMustExist
  Calls CheckFileMustExist to ensure that the file already exists on the local file system. A message is displayed if the file name and extension are not found, and the method is exited.
ofNoReadOnlyReturn
  The file and / or directory in AFilename must be writable. A rsfdFileReadOnly is displayed if the file or directory is read-only, and the method is exited.

CheckFile is used in the CheckAllFiles method to validate the entries in the Files property.

## Version info

Modified in LCL version 2.2.6 to include an additional helper function (ExtractFilterValues) in the implementation.

## See also

TOpenDialog.Options |  | Options to be used for this dialog.
TOpenDialog.CheckAllFiles |  | Ensures that values in the FileName and Files properties are valid for the Options in the dialog.
TOpenDialog.CheckFileMustExist |  | Determines whether the specified file name exists.
TFileDialog.Files |  | Stores the names of files (or directories) selected using the dialog.
TFileDialog.FileName |  | Contains the UTF-8-encoded name for a file chosen using the dialog.
TFileDialog.DefaultExt |  | Contains the default extension for file names in the dialog.
TFileDialog.Filter |  | A string which contains available filename filters used to select files by their file extensions.
TFileDialog.FilterIndex |  | This property sets which file filter is the default.
TOpenOption |  | Options which can be used in a TOpenDialog instance.