function AppendOrWriteTextToFile(FileName : TFilename; WriteText : string): boolean;
var
f : Textfile;
begin
Result := False;
AssignFile(f, FileName);
try
if FileExists(FileName) = False then
Rewrite(f)
else
begin
Append(f);
end;
Writeln(f, WriteText);
Result := True;
finally
CloseFile(f);
end;
end;
Beispiel :
procedure TForm1.Button1Click(Sender: TObject);
var
dir, log : string;
begin
dir := ExtractFilePath(Application.Exename);
log := ListBox1.Items.Text; // STRING WIRD AUS EINER LISTBOX HINZUGEFÜGT
AppendOrWriteTextToFile(dir + '\temp.txt', log)
end;
Keine Kommentare:
Kommentar veröffentlichen