filedelphicreatefile

How would I create a text file in Delphi


I have a program where users register for my program and a text file is created for them. I have tried using the CreateFile function but am not sure on the parameters. How would I create a textfile for each user as they register using this, or any other function?


Solution

  • Maybe you can create a stringlist and save that to file:

    procedure MakeAStringlistAndSaveThat;
    var
      MyText: TStringlist;
    begin
      MyText:= TStringlist.create;
      try
        MyText.Add('line 1');
        MyText.Add('line 2');
        MyText.SaveToFile('c:\folder\filename.txt');
      finally
        MyText.Free
      end; {try}
    end;