type
TBuffer = array [0..16000]of ansichar;
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ss: TFileStream;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
FileName = 'c:\aa.txt';
var
buf: TBuffer;
begin
if not Assigned(ss) then
begin
if FileExists(FileName) then
begin
ss := TFileStream.Create(FileName, fmOpenReadWrite);
ss.Seek(0, soEnd);
end
else
ss := TFileStream.Create(FileName, fmCreate);
end;
StrPcopy(buf, Ansistring(memo1.Lines.Text));
ss.WriteBuffer(buf[1], length(ansistring(memo1.Lines.Text)));
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Freeandnil(ss);
end;
转载于:https://my.oschina.net/u/582827/blog/1542872