Unit 'sysutils' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

FileExists

Check whether a particular file exists in the file system.

Declaration

Source position: filutilh.inc line 224

function FileExists(

  const FileName: UnicodeString;

  FollowLink: Boolean = True

):Boolean;

function FileExists(

  const FileName: RawByteString;

  FollowLink: Boolean = True

):Boolean;

Description

FileExists returns True if a file with name FileName exists on the disk, False otherwise. On windows, this function will return False if a directory is passed as FileName.

On Unixes, passing a directory name used to result in True. (The rationale is that on UNIX, a directory is a file as well). As of version 3.2.0, this behaviour has been changed for a Delphi-compatible approach.

Note that this function accepts a single filename as an argument, without wildcards. To check for the existence of multiple files, see the FindFirst function.

Errors

None.

See also

FindFirst

  

Start a file search and return a findhandle.

FileAge

  

Return the timestamp of a file.

FileGetAttr

  

Return attributes of a file.

FileSetAttr

  

Set the attributes of a file.

Example

Program Example38;

{ This program demonstrates the FileExists function }

Uses sysutils;

Begin
  If FileExists(ParamStr(0)) Then
    Writeln ('All is well, I seem to exist.');
End.

Documentation generated on: Nov 22 2024