Код: Выделить всё
procedure UpdateFilesD(partstr:string);
function DirectoryName(name: string): boolean;
begin
result := (name > '.') and (name > '..');
end;
var
sr: TSearchRec;
li: TListItem;
fi: TSHFileInfo;
ext: string;
IconIndex: word;
ic: TIcon;
sz:int64;
begin
if FindFirst(partstr + '*.*', faAnyFile, sr) = 0 then
repeat
if (sr.Attr and faDirectory > 0) then
begin
if DirectoryName(sr.name) then begin
UpdateFilesD(partstr+sr.name+'\');
continue;
end
else
continue;
end;
li := Form1.ListView1.Items.Add;
li.Caption := partstr+sr.name;
ext := LowerCase(ExtractFileExt(li.Caption));
ShGetFileInfo(PChar('*' + ext), 0, fi, SizeOf(fi),
SHGFI_SMALLICON or SHGFI_SYSICONINDEX or SHGFI_TYPENAME);
li.ImageIndex := fi.iIcon;
sz:=sr.FindData.nFileSizeHigh*256*256*256*256+sr.FindData.nFileSizeLow;
if (sz / 1024) < 1024 then
li.SubItems.Add(IntToStr(round(sz / 1024)) + ' byte')
else
if (sz / 1024) < 1024 * 1024 then
li.SubItems.Add(IntToStr(round((sz / 1024) / 1024)) + ' KByte')
else
if (sz / 1024) < 1024 * 1024 * 1024 then
li.SubItems.Add(IntToStr(round(sz / 1024 / (1024 * 1024))) + ' MByte')
else
li.SubItems.Add(IntToStr(round(sz / 1024 / (1024 * 1024 * 1024))) + ' GByte');
li.SubItems.Add(fi.szTypeName);
until
FindNext(sr) <> 0;
if fldir=true then
begin
li := Form1.ListView1.Items.Add;
li.Caption := partstr;
end else
fldir:=true;
FindClose(sr);
end;
Код: Выделить всё
Form1.ListView1.Items.BeginUpdate;
Form1.ListView1.Items.Clear;
UpdateFilesD(partstr);
Form1.ListView1.Items.EndUpdate;
Правда в процедуре много лишнего но кому надо уберет ))