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

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

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

uses
  System.IO;

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

begin
  // Create a FileInfo object for a text file
  FileInfo := System.IO.FileInfo.Create('C:\DelphiBasics.txt');

  // Open the file for writing
  Writer := FileInfo.CreateText;

  // 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 := FileInfo.AppendText;

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

  // Close the file
  Writer.Close;

  // Re-open for reading
  Reader := FileInfo.OpenText;

  // 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