Home  |  Delphi .net Home  |  System.IO.FileStream  |  WriteByte Method
  
WriteByte  
Method  
Write a byte to the current stream
FileStream Class
System.IO NameSpace
CF1.  Procedure WriteByte ( ByteValue : Byte ) ;
CF : Methods with this mark are Compact Framework Compatible
Description
Thje ByteValue is written to the current position in the stream. The position is updated accordingly.
Microsoft MSDN Links
System.IO
System.IO.FileStream
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

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

uses
  System.IO;

var
  Stream        : System.IO.FileStream;
  ByteAsInteger : Integer;

begin
  // Open the file for writing
  Stream := System.IO.FileStream.Create('C:\DelphiBasics.txt',
                                        FileMode.Create);

  // Write to the file
  Stream.WriteByte(65);  // Chr(65) = 'A'
  Stream.WriteByte(66);  // Chr(66) = 'B'
  Stream.WriteByte(67);  // Chr(67) = 'C'

  // Move to the start of the file
  Stream.Seek(0, SeekOrigin.Begin);

  // Display the contents
  ByteAsInteger := Stream.ReadByte;
  while ByteAsInteger >= 0 do
  begin
    Console.Write(Char(ByteAsInteger));
    ByteAsInteger := Stream.ReadByte;
  end;

  // Close the stream
  Stream.Close;

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