///////////////////////////////////////////////////////////////////
procedure TForm1.ClientDataset1AfterScroll(DataSet: TDataSet);
begin
if DataSet.IsEmpty then exit;
try
if (not clientdataset1Field1.IsNull) and
(clientdataset1Field1.AsString <> '') then
Memo.Text := zlibex.ZDeCompressStr( clientdataset1Field1.AsString)
else SysPrepStrings.Text := '';
except
on E:Exception do
begin
end;
end;
end;
///////////////////////////////////////////////////////////////////
procedure Form1.ClientDataset1GetText(Sender: TField;
var Text: string; DisplayText: Boolean);
begin
if not (Sender is TMemoField) then exit;
if TMemoField(Sender).AsString = '' then exit;
try
if (not clientdataset1Field1.IsNull) and
(clientdataset1Field1.AsString <> '') then
Text := zlibex.ZDeCompressStr(clientdataset1Field1.AsString)
else Text := '';
except
on E:Exception do
begin
end;
end;
Memo1.Text := Text;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
tamanhoTotal := 0;
memLista.Lines.Clear;
ListarArquivos(edtDiretorio.Text, chkSub.Checked);
Edit1.Text := IntToStr( tamanhoTotal );
end;
procedure TForm1.ListarArquivos(Diretorio: string; Sub:Boolean);
var
F: TSearchRec;
Ret: Integer;
TempNome: string;
begin
Ret := FindFirst(Diretorio+'\*.*', faAnyFile, F);
try
while Ret = 0 do
begin
if TemAtributo(F.Attr, faDirectory) then
begin
if (F.Name <> '.') And (F.Name <> '..') then
if Sub = True then
begin
TempNome := Diretorio+'\' + F.Name;
ListarArquivos(TempNome, True);
end;
end
else
begin
memLista.Lines.Add(Diretorio+'\'+F.Name);
tamanhoArquivo( Diretorio+'\'+F.Name );
end;
//
Ret := FindNext(F);
end;
finally
begin
FindClose(F);
end;
end;
end;
function TForm1.TemAtributo(Attr, Val: Integer): Boolean;
begin
Result := Attr and Val = Val;
end;
procedure TForm1.tamanhoArquivo(Arq: String);
var
SR: TSearchRec;
I: integer;
begin
I := FindFirst(arq, faArchive, SR);
try
if I = 0 then
tamanhoTotal := tamanhoTotal + ( SR.Size );
finally
FindClose(SR);
end;
end;
end.
to list files: use TSearchRec and FindFirst, FindNext
lots of links here:
http://www.torry.net/search.htm
to compress, you need to think about the component you need to use
http://www.torry.net/pages.php?s=99
http://www.torry.net/pages.php?id=302
http://www.torry.net/pages.php?id=303
Moon ???