FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Temas de Hoy |
|
Herramientas | Buscar en Tema | Desplegado |
#1
|
|||
|
|||
Renombrar, eliminar ficheros con Delphi????
Hola gente,
estoy intentando realizar un pequeño módulo que me elimine unos determinados ficheros (una extensión concreta) de un directorio. Tambien necesitaria renombrar un fichero con un nombre concreto. Todo ello debo implementarlo desde una aplicacion Delphi, pero ahora mismo no se como realizarlo. Conoceis de algunos ejemplos interesantes?. Saludos y felices Fiestas. Miguel |
#2
|
|||
|
|||
Código:
procedure TForm1.BuscaFicheros(path, mask : AnsiString; var Value : TStringList; brec : Boolean); var srRes : TSearchRec; iFound : Integer; begin if ( brec ) then begin if path[Length(path)] <> '\' then path := path +'\'; iFound := FindFirst( path + '*.*', faAnyfile, srRes ); while iFound = 0 do begin if ( srRes.Name <> '.' ) and ( srRes.Name <> '..' ) then if srRes.Attr and faDirectory > 0 then BuscaFicheros( path + srRes.Name, mask, Value, brec ); iFound := FindNext(srRes); end; FindClose(srRes); end; if path[Length(path)] <> '\' then path := path +'\'; iFound := FindFirst(path+mask, faAnyFile-faDirectory, srRes); while iFound = 0 do begin if ( srRes.Name <> '.' ) and ( srRes.Name <> '..' ) and ( srRes.Name <> '' ) then Value.Add(path+srRes.Name); iFound := FindNext(srRes); end; FindClose( srRes ); end; lo llamas asi Código:
procedure TForm1.Button1Click(Sender: TObject); var Ficheros:TStringList; begin Ficheros:=TStringList.Create; BuscaFicheros('c:\delphi3\','*.*',Ficheros,TRUE); Memo1.Lines.Assign(Ficheros); Ficheros.Free; end; Con este procedimiento los localizas, y los eliminas o lo que quieras Saludos |
#3
|
|||
|
|||
Muchas gracias, tio.
Ya he conseguido implementarlo. Tu ejemplo me ha servido de bastante ayuda. Saludos y felices fiestas. |
|
|
|