Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 01-02-2011
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is online now
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 19.437
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
A mi me funciona algo como esto (además puedes hacerlo recursivo):

Código Delphi [-]
var
  TS:TStringList;
  i:Integer;
begin

  try
    TS := TStringList.Create();
    FindFiles('c:\windows\temp', '*.*', True, TS);
    for i := 0 to (TS.Count - 1) do begin
      DeleteFile(TS[i]);
    end;
  finally
    FreeAndNil(TS);
  end;

La función FindFiles se puede encontrar en la sección de trucos del club.

Código Delphi [-]
procedure FindFiles(StartDir, FileMask: string; recursively: boolean; var FilesList: TStringList);
var
  SR: TSearchRec;
  DirList: TStringList;
  IsFound: Boolean;
  i: integer;
const
  CHAR_BACKSLASH = '\';
  MASK_ALL_FILES = '*.*';
  CHAR_POINT = '.';
begin
  if (StartDir[length(StartDir)] <> CHAR_BACKSLASH) then begin
    StartDir := StartDir + CHAR_BACKSLASH;
  end;

  // Crear la lista de ficheos en el directorio StartDir (no directorios!)
  IsFound := FindFirst(StartDir + FileMask, faAnyFile - faDirectory, SR) = 0;
  // MIentras encuentre
  while IsFound do  begin
    FilesList.Add(StartDir + SR.Name);
    IsFound := FindNext(SR) = 0;
  end;

  FindClose(SR);

  // Recursivo?
  if (recursively) then begin
    // Build a list of subdirectories
    DirList := TStringList.Create;
    // proteccion
    try
      IsFound := FindFirst(StartDir + MASK_ALL_FILES, faAnyFile, SR) = 0;
      while IsFound do
      begin
        if ((SR.Attr and faDirectory) <> 0) and
          (SR.Name[1] <> CHAR_POINT) then
          DirList.Add(StartDir + SR.Name);
        IsFound := FindNext(SR) = 0;
      end;
      FindClose(SR);

      // Scan the list of subdirectories
      for i := 0 to DirList.Count - 1 do
        FindFiles(DirList[i], FileMask, recursively, FilesList);
    finally
      DirList.Free;
    end;
  end;
end;
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Como saber la ubicacion de la carpeta Windows JoAnCa API de Windows 3 10-12-2010 17:23:18
Borrar archivos dentro de carpeta ØnLy Varios 1 23-11-2010 06:36:55
Como eliminar una carpeta y todos sus archivos? Ayudaa Supra Varios 5 15-07-2008 14:12:43
Obtener el Path de TEMP de windows sin ~ apicito OOP 5 09-04-2008 16:27:46
como obtener el numero de archivos que contiene una carpeta Javi2 Varios 1 15-07-2004 12:03:21


La franja horaria es GMT +2. Ahora son las 14:47:50.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi