Ver Mensaje Individual
  #2  
Antiguo 24-10-2023
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.734
Reputación: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Has una prueba básica antes de nada...
Quizás solo te falta una contrabarra o está mal escrito el nombre de la carpeta.

Agrega un TMemo (MDebug) y un TEdit (EDirFileExists) a un formulario.
Código Delphi [-]
procedure TFMPruebas.BFileExistsClick(Sender: TObject);
var
  sr : TSearchRec;
  RegistrosEncontrados : integer;
begin
  inherited;
  // Borro contenido de memo
  MDebug.Lines.Clear;

  // Me aseguro que la direccion termine en "\"
  EDirFileExists.Text := IncludeTrailingPathDelimiter(EDirFileExists.Text);

  // Busco los archivos dentro el directorio 
  RegistrosEncontrados := FindFirst(EDirFileExists.Text + '*.*', faAnyFile, sr);
  try
     // Mientras haya archivos...
     while RegistrosEncontrados = 0 do
     begin
        // Si el archivo no es uno "especial"
        if not ((sr.Name = '.') or (sr.Name = '..')) then
        begin
           // Si es un directorio lo menciono pero no hago nada
           if ((sr.Attr and faDirectory) = faDirectory) then
              MDebug.Lines.Add(format('Directorio: %s', [sr.Name]))
           else
           begin
              // Compruebo funcionamiento de funcion FileExists()
              if FileExists(EDirFileExists.Text + sr.Name) then
                 MDebug.Lines.Add(format('Existe archivo: %s', [EDirFileExists.Text + sr.Name]))
              else
                 MDebug.Lines.Add(format('NO Existe archivo: %s', [EDirFileExists.Text + sr.Name]))
           end;
        end;
        // Busco el siguiente archivo
        RegistrosEncontrados := FindNext(sr);
     end;
  finally
     SysUtils.FindClose(sr);
  end;
end;

Última edición por duilioisola fecha: 24-10-2023 a las 18:16:00.
Responder Con Cita