1
I am locating and saving the files in a listbox1, as follows:
procedure Localizar(DIR,ARQ: string; LIST: TStrings);
var
SR: TSearchRec;
begin
{Garante a barra no final do diretório}
if DIR[length(DIR)] <> '\' then
DIR := DIR + '\';
{Encontra os arquivos e diretórios segundo o definido em ARQ}
if FindFirst(DIR + ARQ, faAnyFile, SR) = 0 then
repeat
if (SR.Name <> '.') and (SR.Name <> '..') then
begin
LIST.Add(DIR + SR.Name); //Grava o arquivo/diretório encontrado num TStrings
Application.ProcessMessages; //Essa linha pode ser eliminada se executar a procedure numa outra thread
end
until FindNext(SR) <> 0;
{Busca os subdiretórios de DIR}
if FindFirst(DIR + '*.*', faAnyFile, SR) = 0 then
repeat
if SR.Attr = faDirectory then
begin
if (SR.Name <> '.') and (SR.Name <> '..') then
begin
Localizar(DIR + SR.Name, ARQ, LIST); //Reinicia a busca no subdiretório encontrado
Application.ProcessMessages; //Essa linha pode ser eliminada se executar a procedure numa outra thread
end;
end;
until FindNext(SR) <> 0;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Localizar('C:\Usina_Comvap_ex', '*.dbf', ListBox1.Items);
end;
and after locating that file, I would like to transfer them to another folder as follows:
procedure TForm1.Button3Click(Sender: TObject);
var
Origem:string;
Destino:string;
i : Integer;
begin
for i := 0 to listbox1.items.Count-1 do
begin
Origem:=listbox1.items[1];
Destino:='C:\Users\Guilherme\Desktop\shp\'+ExtractFileName(listbox1.items[i]);
CopyFile(PChar(Origem), PChar(Destino), true);
end;
end;
ok, it copies the files but while trying to open it comrrompes the files:
disagree, on the source path, I can open . dbf correctly,
– Guilherme Lima
@Guilhermelima, with Excel ?
– Victor Tadashi
yes, or liboffice
– Guilherme Lima
You can share the file ?
– Victor Tadashi