Señores, buenos dias. El que poasa es que mi aplicacion me lo da error de Access Violation quando yo intento llenar la lista con archivo. Vea abajo mi unit y mi codigo.
Código Delphi
[-]procedure TFileFinder.Start;
procedure PathFound(const Path: string);
var
Dir,texto,txt1,txt2: string;
Mask: string;
SR: TSearchRec;
erro,posicao,i:integer;
Lista:TList<String>;
nome,novo_nome,s: String;
begin
if Assigned(Lista) then
Lista := TList<string>.Create();
Dir := IncludeTrailingPathDelimiter(Path);
if not AceitarDirectory(Dir) then
Exit;
Mask := Dir + '*.*';
if Active and (FindFirst(Mask, faAnyFile - faDirectory, SR) = 0) then
try
repeat
inc(cont);
texto := '-'+StrZero(cont,4);
nome := Copy(SR.Name,1,Length(SR.Name)- 4);
if muda = 0 then
begin
Lista.AddRange([nome]); txt1 := Dir + SR.Name;
Insert(texto,SR.Name,21);
txt2 := Dir + SR.Name;
end
else
begin
for i := 0 to Lista.Count - 1 do
begin
novo_nome := Copy(SR.Name,1,Length(SR.Name)- 4);
if novo_nome = Lista.Items[i] then
txt1 := Dir + novo_nome;
Insert(texto,novo_nome,21);
txt2 := Dir + novo_nome;
end;
end;
RenameFile(txt1,txt2);
until (FindNext(SR) <> 0) or (not Active);
finally
FindClose(SR);
end;
Mask := Dir + '*.*';
OnDir := Mask;
if Active and Recursive and (FindFirst(Mask, faDirectory, SR) = 0) then
try
repeat
if (SR.Name <> '.') and (SR.Name <> '..') then
begin
PathFound(Dir + SR.Name);
posicao := (Pos('PDF',SR.Name)) or (Pos('TIF',SR.Name))or (Pos('TXT',SR.Name));
if posicao > 0 then
cont := 0;
inc(muda);
end;
until (FindNext(SR) <> 0) or (not Active);
finally
FindClose(SR);
end;
end;
begin
PathFound(fStartPath);
Active := false;
end;