Home  |  Delphi .net Home  |  System.IO.File  |  AppendText Method
  
AppendText  
Method  
Returns a StreamWriter object allowing appending to the specified file
File Class
System.IO NameSpace
CF1.  Function AppendText ( PathString : String ) : StreamWriter; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
A StreamWriter object is returned allowing write access to the file specified in PathString, position starting at the end of the current file contents.
References
StreamWriter
Microsoft MSDN Links
System.IO
System.IO.File
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

uses
  System.IO;

var
  Path   : String;
  Reader : System.IO.StreamReader;
  Writer : System.IO.StreamWriter;
  MyByte : Integer;

begin
  // Open the file for writing
  Path := 'C:\DelphiBasics.txt';
  Writer := System.IO.File.CreateText(Path);

  // Write to the file
  Writer.Write('A');
  Writer.Write('B');
  Writer.Write('C');

  // Close the file
  Writer.Close;

  // Open the file for appending to
  Writer := System.IO.File.AppendText(Path);

  // Write some more lines to the file
  Writer.Write('D');
  Writer.Write('E');

  // Close the file
  Writer.Close;

  // Re-open for reading
  Reader := System.IO.File.OpenText(Path);

  // Display the contents
  Console.WriteLine(Reader.ReadToEnd);

  // Close the file
  Reader.Close;

  Console.Readline;
end.
   ABCDE
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author