08-01-2011، 07:13 PM
Get SIZE FiLE Delphi
منبع mt88
کد:
function GetFileSizeOnDisk(const FileName: TFileName): Cardinal;
var
spc,bps,nofc,tnoc : Cardinal;
ClusterSize,
ClustersCount,
FileSize : Cardinal;
begin
Result := 0;
if not FileExists(FileName) then
Exit;
//Call GetDiskFreeSpace to find out disk cluster size.
if not GetDiskFreeSpace(PAnsiChar(ExtractFileDrive(FileNa me)),spc,bps,nofc,tnoc) then
Exit;
//Cluster size = Bytes Per Sector * Sectors Per Cluster
ClusterSize := bps * spc;
//Get actual file size.
FileSize := GetCompressedFileSize(PAnsiChar(FileName),nil);
ClustersCount := FileSize div ClusterSize;
//Calculate file size on the disk.
Result := ClustersCount * ClusterSize;
//if the file occupies a cluster partially, add cluster size to file size, because
//a cluster is the smallest unit of disk which is accesible.
if FileSize > Result then
Inc(Result,ClusterSize);
end;
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg