Fórum Procurar arquivos no computador #397037
10/03/2011
0
procedure TForm5.BProcurarClick(Sender: TObject);
var FilesList : TStringList;
begin
FilesList := TStringList.Create;
findfiles(FilesList,'c:','*.*',true);
LEncontrado.Items.Assign(Fileslist);
end;
procedure TForm5.FindFiles(FilesList: TStringList; StartDir, Mascara: string; IncludeRoot:boolean);
var
SR: TSearchRec;
ListaDir: TStringList;
IsFound: Boolean;
i,l: integer;
begin
if length(StartDir)<>0 then
if StartDir[length(StartDir)] <> '\' then
begin
StartDir := StartDir + '\';
end;
for l:=0 to LComparar.Count-1 do
begin
Mascara:=LComparar.Items[l];
IsFound :=FindFirst(StartDir+Mascara, faAnyFile-faDirectory, SR) = 0;
while IsFound do begin
FilesList.Add(StartDir + SR.Name);
IsFound := FindNext(SR) = 0;
end;
FindClose(SR);
end;
if IncludeRoot=true then
begin
// Cria lista de subdirectorios
ListaDir := TStringList.Create;
IsFound := FindFirst(StartDir+'*.*', faAnyFile, SR) = 0;
while IsFound do begin
if ((SR.Attr and faDirectory)<>0) and
(SR.Name[1] <> '.') and (SR.Name <> 'Windows') then
ListaDir.Add(StartDir + SR.Name);
LProcurando.Items.Assign(ListaDir);
IsFound := FindNext(SR) = 0;
end;
FindClose(SR);
// Procura dentro da lista
for i := 0 to ListaDir.Count - 1 do
FindFiles(FilesList, ListaDir[i], Mascara,includeroot);
ListaDir.Free;
end;
end;
nesse codigo qnd eu clico em um botao "BProcurar" ele começa a busca, procurando arquivos com o nome de "LComparar" e se achado coloca em "LEncontrado". alguem pode me ajudar?
Guilherme Marini
Curtir tópico
+ 0Posts
10/03/2011
Leonardo Xavier
Gostei + 0
10/03/2011
Guilherme Marini
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)