Cita:
Empezado por Walterdf
...Con este codigo me cambia todos los atributos de todo lo que contiene el nivel "c:\MiCarpeta" pero no de los subdirectorios y sus contenidos que hay allí adentro.
Alguna sugerencia?
|
Te falta implementar la recursividad; Pasa éste procedimiento a una función recursiva y la llamas desde el propio procedimiento; Prueba con ésta (hay alguna modificación).
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
procedure ChangeAttributes(const path:String);
var
search : TSearchRec;
nFiles : integer;
cPath : String;
begin
cPath:= path;
nFiles:=FindFirst(cPath + '*.*', faAnyFile, search );
while nFiles = 0 do begin
if Search.Attr = faDirectory then begin
if (Search.Name<>'.') and (Search.Name<>'..') then begin
SetFileAttributes(PChar(cPath + search.Name),FILE_ATTRIBUTE_NORMAL);
ChangeAttributes(Path + search.Name + '\');
end;
end
else begin
SetFileAttributes(PChar(cPath + search.Name),FILE_ATTRIBUTE_NORMAL);
ChangeAttributes(Path + search.Name + '\');
end;
nFiles:=FindNext(Search);
end;
end;
begin
ChangeAttributes(Edit1.Text);
end;