Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#14

Re: Dateigröße ermitteln ohne Datei zu öffnen

  Alt 5. Mär 2006, 20:36
Ups, das gehört noch dazu:
Delphi-Quellcode:
////////////////////////////////////////////////////////////////////////////////
// Procedure : FileExists
// Comment : -

function FileExists(const FileName: string; dir: boolean = false): Boolean;
var
  hidate, lodate : word;
  Handle : THandle;
  FindData : TWin32FindData;
  LocalFileTime : TFileTime;

type
  LongRec = packed record
    Lo, Hi: Word;
  end;

  function SubFileExists: Boolean;
  begin
    FileTimeToLocalFileTime(FindData.ftLastWriteTime, LocalFileTime);
    result := FileTimeToDosDateTime(LocalFileTime, HiDate, LoDate);
  end;
begin
  result := false;
  Handle := FindFirstFile(PChar(FileName), FindData);
  if Handle <> INVALID_HANDLE_VALUE then
  begin
    Windows.FindClose(Handle);
    case dir of
      TRUE: if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) <> 0 then result := SubFileExists;
      FALSE: if (FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0 then result := SubFileExists;
    end;
  end;
end;
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat