Ver Mensaje Individual
  #3  
Antiguo 15-05-2015
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
albelg,

Cita:
Empezado por albelg
...como abrir varios archivos.txt en un mismo memo...
¡Bienvenido al Club Delphi!

Revisa este código:
Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
   openDialog : TOpenDialog;
   FileList : TStringList;

begin

   openDialog := TOpenDialog.Create(self);
   openDialog.InitialDir := GetCurrentDir;
   openDialog.Options := [ofFileMustExist];
   openDialog.Filter := 'Text Files | *.txt';

   if openDialog.Execute then
   begin
      FileList := TStringList.Create;
      FileList.LoadFromFile(openDialog.FileName);
      Memo1.Text := Memo1.Text + FileList.Text;
   end;

   openDialog.Free;
   FileList.Free;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   Memo1.Clear;
end;

end.
El código anterior en Delphi 7 sobre Windows 7 Professional x32, Permite abrir varios archivos .txt dentro de un TMemo uno a continuación del otro, como se muestra en la siguiente imagen:



Espero sea útil

Nelson.
Responder Con Cita