FileExists verwendet intern
FileAge!
Wenn deine Datei also kein "gescheites" Datum hat, existiert sie für die
VCL nicht.
Interessant, was da manchmal so entdeckt wird.
Delphi-Quellcode:
function FileAge(
const FileName:
string): Integer;
var
Handle: THandle;
FindData: TWin32FindData;
LocalFileTime: TFileTime;
begin
Handle := FindFirstFile(PChar(FileName), FindData);
if Handle <> INVALID_HANDLE_VALUE
then
begin
Windows.FindClose(
Handle);
if (FindData.dwFileAttributes
and FILE_ATTRIBUTE_DIRECTORY) = 0
then
begin
FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);
if FileTimeToDosDateTime(LocalFileTime, LongRec(Result).Hi,
LongRec(Result).Lo)
then Exit;
end;
end;
Result := -1;
end;
function FileExists(
const FileName:
string): Boolean;
begin
Result := FileAge(FileName) <> -1;
end;
PS: so klappt auch mit dem Nachbarn:
Delphi-Quellcode:
function FileExists(const FileName: string): Boolean;
var
Attr: Cardinal;
begin
Attr := GetFileAttributes(Pointer(Filename));
Result := (Attr <> $FFFFFFFF) and (Attr and FILE_ATTRIBUTE_DIRECTORY = 0);
end;