Und jezt noch als Funktion
Delphi-Quellcode:
function GetRealFileSize (const drive : Char; const filesize : Cardinal) : Cardinal;
var
ClusterSize: Cardinal;
SectorPerCluster : Cardinal;
BytesPerSector : Cardinal;
NumberOfFreeClusters : Cardinal;
TotalNumberOfClusters: Cardinal;
realsize : Cardinal;
begin
GetDiskFreeSpace(PChar(drive +':\'), SectorPerCluster,BytesPerSector, NumberOfFreeClusters, TotalNumberOfClusters);
ClusterSize:=SectorPerCluster * BytesPerSector;
if not ((filesize MOD clustersize) = 0) then
begin
realsize := ((filesize div clustersize) * clustersize) + clustersize
end
else
begin
realsize := filesize;
end;
result := realsize;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage (IntToStr (GetRealFileSize('c',4096)));
end;
Stephan B.
"Lasst den Gänsen ihre Füßchen"