Answer the question
In order to leave comments, you need to log in
How to check if a file is empty in Delphi?
Greetings.
There was a need to make a condition for checking the .txt text file for emptiness (there is nothing there, including whitespace characters, line feeds, carriage returns, etc.). Did an existence check.
I will be grateful.
Answer the question
In order to leave comments, you need to log in
type
TFileState = ( fsMissing, fsEmpty, fsSomething );
function GetFileState(s : string) : TFileState;
var
sr : TSearchRec;
err : integer;
begin
err := FindFirst(s, faAnyFile and not faDirectory, sr);
if err <> 0
then Result := fsMissing
else if sr.Size = 0
then Result := fsEmpty
else Result := fsSomething;
FindClose(sr);
end;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question