[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'FileUtil' (#lazutils)

FileIsInPath

Checks whether the specified file name shares the path specified in Path.

Declaration

Source position: fileutil.pas line 65

function FileIsInPath(

  const Filename: string;

  const Path: string

):Boolean;

Arguments

Filename

  

The name of the file examined in the routine.

Path

  

The path name examined in the routine.

Function result

Returns True the arguments share the same path information.

Description

FileIsInPath is a Boolean function used to determine whether the file in FileName is located in the specified Path. FileIsInPath calls the CleanAndExpandFilename and CleanAndExpandDirectory routines to resolve drive letters or relative path information included in the arguments.

The return value is True when the resolved paths for the arguments contain the same values. FileIsInPath does not verify whether Path or FileName actually exist on the local file system. It compares the specified string values only.

Use DirectoryExists or DirectoryExistsUTF8 to determine whether a path exists on the local file system.

Use FileExists or FileExistsUTF8 to determine whether a file exists on the local file system.

Example:

// uses FileUtil;
// ...
// var
//   sDir, sFile: String;
//   bResult: Boolean;
// ...
// neither the file nor the directory exist on the file system
sDir := 'q:\bogus\path\';
sFile := 'q:\bogus\path\..\path\filename.ext';
bResult := FileIsInPath(sFile, sDir);

ShowMessage('File: ' + sFile + LineEnding +
  'is in Path: ' + sDir + '?' + LineEnding +
  'FileIsInPath() result is: ' + bResult.ToString(TUseBoolStrs.True) + '.');

See also

FileIsInDirectory

  

Checks whether the specified file name shares the path specified in Directory.

CleanAndExpandFilename

  

Removes whitespace and resolves special characters in the specified file name.

CleanAndExpandDirectory

  

Removes whitespace and resolves special characters in the specified path.

CompareFileNames

  

Gets the relative sort order for the specified file names.


Version 3.2 Generated 2024-02-25 Home