unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
ButtonLoad: TButton;
ButtonSave: TButton;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
procedure ButtonLoadClick(Sender: TObject);
procedure ButtonSaveClick(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ButtonLoadClick(Sender: TObject);
var
StringList: TStringList;
begin
if OpenDialog1.Execute then
begin
StringList := TStringList.Create;
try
StringList.LoadFromFile(OpenDialog1.FileName);
ListBox1.Items.Assign(StringList);
finally
StringList.Free;
end;
end;
end;
procedure TForm1.ButtonSaveClick(Sender: TObject);
var
StringList: TStringList;
begin
if SaveDialog1.Execute then
begin
StringList := TStringList.Create;
try
StringList.Assign(ListBox1.Items);
StringList.SaveToFile(SaveDialog1.FileName);
finally
StringList.Free;
end;
end;
end;
end.