var
i: integer;
b: tsearchrec;
begin
SetCurrentDir('\\COMPRAS20HP\Users\Slim4-core\Desktop\Slimstock_ficheros_export\');
i:= findfirst('*.txt', faAnyFile, b);
while i=0 do
begin
showmessage(b.name);
i:=findnext(b);
end;
findclose(b);
http://www.delphibasics.co.uk/RTL.php?Name=findfirst
Attribute constants and values
| Constant | Value | Description |
|---|---|---|
faReadOnly | $00000001 | Read-only files |
faHidden | $00000002 | Hidden files |
faSysFile | $00000004 | System files |
faVolumeID | $00000008 | Volume ID files |
faDirectory | $00000010 | Directory files |
faArchive | $00000020 | Archive files |
faAnyFile | $0000003F | Any file |
TIPO TSearchRec
type
TSearchRec = record
Time: Integer;
Size: Integer;
Attr: Integer;
Name: TFileName;
ExcludeAttr: Integer;
FindHandle: THandle;
FindData: TWin32FindData;
end;
OTRO EJEMPLO
procedure TFPrincipal.Listar( sDirectorio: string; var Resultado: TStringList );
var
Busqueda: TSearchRec;
iResultado: Integer;
begin
// Nos aseguramos que termine en contrabarra
sDirectorio := IncludeTrailingBackslash( sDirectorio );
iResultado := FindFirst( sDirectorio + '*.*', faAnyFile, Busqueda);
while iResultado = 0 do
begin
// ¿Ha encontrado un archivo y no es un directorio?
if ( Busqueda.Attr and faArchive = faArchive ) and
( Busqueda.Attr and faDirectory <> faDirectory ) then
Resultado.Add( Busqueda.Name );
iResultado := FindNext( Busqueda );
end;
FindClose( Busqueda );
end;
