Is It a Directory/Folder?
It is often useful to determine if an entry in a file directory is a directory/folder or a file. Here is a simple Delphi function that takes a path as its input, determines if the path points to a directory/folder, and returns true or false. This function is very useful for working with directories/folders and files. For additional Delphi code for the Windows operating system, see
Useful Delphi Code for the Windows Operating System.
function IsDirectory(FullFileName: String): Boolean;
var
TheAttributes: Integer;
begin
IsDirectory := False;
TheAttributes := 0;
If FullFileName <> '' then
begin
TheAttributes := FileGetAttr(FullFileName);
If ((TheAttributes and faDirectory) = faDirectory) then IsDirectory := True;
end;
end;
Posted: Saturday, May 13, 2023
Last updated: Saturday, May 20, 2023