mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00] 1.0.5000.0 2.0.0.0 4.0.0.0 Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details. System.Object System.IDisposable System.Runtime.InteropServices.ComVisible(true)

The class provides methods that simplify writing primitive data types to a stream. For example, you can use the method to write a Boolean value to the stream as a one-byte value. The class includes write methods that support different data types.

When you create a new instance of the class, you provide the stream to write to, and optionally specify the type of encoding and whether to leave the stream open after disposing the object. If you do not specify an encoding type, UTF-8 is used.

A derived class can override the methods of this class to give unique character encodings.

Writes primitive types in binary to a stream and supports writing strings in a specific encoding.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  For a list of common I/O tasks, see Common I/O Tasks.

  Initializes a new instance of the class that writes to a stream.

- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  For a list of common I/O tasks, see Common I/O Tasks.

  Initializes a new instance of the class based on the specified stream and using UTF-8 encoding.

  The output stream.
- Constructor
  1.0.5000.0
  2.0.0.0
  4.0.0.0

  For a list of common I/O tasks, see Common I/O Tasks.

  Initializes a new instance of the class based on the specified stream and character encoding.

  The output stream.
  The character encoding to use.
- Constructor
  4.0.0.0
  To be added.

  Initializes a new instance of the class based on the specified stream and character encoding, and optionally leaves the stream open.

  The output stream.
  The character encoding to use.
  true to leave the stream open after the object is disposed; otherwise, false.
- Property
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.Stream To be added: an object of type 'Stream'

  For a list of common I/O tasks, see Common I/O Tasks.

  Gets the underlying stream of the .

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  This implementation of Close calls the method passing a true value.

  Flushing the stream will not flush its underlying encoder unless you explicitly call or Close. Setting to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters.

  Closes the current and the underlying stream.

- Method
  4.0.0.0
  System.Void To be added.

  Releases all resources used by the current instance of the class.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` To be added

  Releases the unmanaged resources used by the and optionally releases the managed resources.

  true to release both managed and unmanaged resources; false to release only unmanaged resources.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void

  All derived classes should override Flush to ensure that all buffered data is sent to the stream.

  Flushing the stream will not flush its underlying encoder unless you explicitly call Flush or . Setting to true means that data will be flushed from the buffer to the stream, but the encoder state will not be flushed. This allows the encoder to keep its state (partial characters) so that it can encode the next block of characters correctly. This scenario affects UTF8 and UTF7 where certain characters can only be encoded after the encoder receives the adjacent character or characters.

  For a list of common I/O tasks, see Common I/O Tasks.

  Clears all buffers for the current writer and causes any buffered data to be written to the underlying device.

- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.BinaryWriter

  For a list of common I/O tasks, see Common I/O Tasks.

  Specifies a with no backing store.

- Field
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.IO.Stream

  For a list of common I/O tasks, see Common I/O Tasks.

  Holds the underlying stream.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Int64 `` ``

  For a list of common I/O tasks, see Common I/O Tasks.

  Sets the position within the current stream.

  The position with the current stream.

  A byte offset relative to . A field of indicating the reference point from which the new position is to be obtained.
- Method
  System.Void

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

  1.0.5000.0
  2.0.0.0
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a one-byte Boolean value to the current stream, with 0 representing false and 1 representing true.

  The Boolean value to write (0 or 1).
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  Because of data formatting conflicts, using this method with the following encodings is not recommended:

  UTF-7

  ISO-2022-JP

  ISCII

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes an unsigned byte to the current stream and advances the stream position by one byte.

  The unsigned byte to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a byte array to the underlying stream.

  A byte array containing the data to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  Because of data formatting conflicts, using this method with the following encodings is not recommended:

  UTF-7

  ISO-2022-JP

  ISCII

  For a list of common I/O tasks, see Common I/O Tasks.

  Unicode surrogate characters must be written out as pairs together in the same call, not individually. If you require support for surrogate pairs in your application, consider using a character array and the method overload.

  Writes a Unicode character to the current stream and advances the current position of the stream in accordance with the Encoding used and the specific characters being written to the stream.

  The non-surrogate, Unicode character to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  The following table lists examples of other typical or related I/O tasks.

  To do this...

  See the example in this topic...

  Create a text file.

  [<topic://cpconwritingtexttofile>]

  Write to a text file.

  [<topic://cpconwritingtexttofile>]

  Read from a text file.

  [<topic://cpconreadingtextfromfile>]

  Append text to a file.

  [<topic://cpconopeningappendingtologfile>]

  Get the size of a file.

  Get the attributes of a file.

  Set the attributes of a file.

  Determine if a file exists.

  Read from a binary file.

  [<topic://cpconReadingWritingToNewlyCreatedDataFile>]

  Write to a binary file.

  [<topic://cpconReadingWritingToNewlyCreatedDataFile>]

  Writes a character array to the current stream and advances the current position of the stream in accordance with the Encoding used and the specific characters being written to the stream.

  A character array containing the data to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  The following table lists examples of other typical or related I/O tasks.

  To do this...

  See the example in this topic...

  Create a text file.

  [<topic://cpconwritingtexttofile>]

  Write to a text file.

  [<topic://cpconwritingtexttofile>]

  Read from a text file.

  [<topic://cpconreadingtextfromfile>]

  Append text to a file.

  [<topic://cpconopeningappendingtologfile>]

  Get the size of a file.

  Get the attributes of a file.

  Set the attributes of a file.

  Determine if a file exists.

  Read from a binary file.

  [<topic://cpconReadingWritingToNewlyCreatedDataFile>]

  Write to a binary file.

  [<topic://cpconReadingWritingToNewlyCreatedDataFile>]

  Writes a decimal value to the current stream and advances the stream position by sixteen bytes.

  The decimal value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes an eight-byte floating-point value to the current stream and advances the stream position by eight bytes.

  The eight-byte floating-point value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  BinaryWriter stores this data type in little endian format.

  The following table lists examples of other typical or related I/O tasks.

  To do this...

  See the example in this topic...

  Create a text file.

  [<topic://cpconwritingtexttofile>]

  Write to a text file.

  [<topic://cpconwritingtexttofile>]

  Read from a text file.

  [<topic://cpconreadingtextfromfile>]

  Append text to a file.

  [<topic://cpconopeningappendingtologfile>]

  Get the size of a file.

  Get the attributes of a file.

  Set the attributes of a file.

  Determine if a file exists.

  Read from a binary file.

  [<topic://cpconReadingWritingToNewlyCreatedDataFile>]

  Write to a binary file.

  [<topic://cpconReadingWritingToNewlyCreatedDataFile>]

  Writes a two-byte signed integer to the current stream and advances the stream position by two bytes.

  The two-byte signed integer to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  BinaryWriter stores this data type in little endian format.

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a four-byte signed integer to the current stream and advances the stream position by four bytes.

  The four-byte signed integer to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  BinaryWriter stores this data type in little endian format.

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes an eight-byte signed integer to the current stream and advances the stream position by eight bytes.

  The eight-byte signed integer to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Void ``

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a signed byte to the current stream and advances the stream position by one byte.

  The signed byte to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  BinaryWriter stores this data type in little endian format.

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a four-byte floating-point value to the current stream and advances the stream position by four bytes.

  The four-byte floating-point value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  Length-prefixed means that this method first writes the length of the string, in bytes, when encoded with the instance's current encoding to the stream. This value is written as an unsigned integer. This method then writes that many bytes to the stream.

  For example, the string “A” has a length of 1, but when encoded with UTF-16; the length is 2 bytes, so the value written in the prefix is 2, and 3 bytes are written to the stream, including the prefix.

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a length-prefixed string to this stream in the current encoding of the , and advances the current position of the stream in accordance with the encoding used and the specific characters being written to the stream.

  The value to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Void ``

  BinaryWriter stores this data type in little endian format.

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a two-byte unsigned integer to the current stream and advances the stream position by two bytes.

  The two-byte unsigned integer to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Void ``

  BinaryWriter stores this data type in little endian format.

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a four-byte unsigned integer to the current stream and advances the stream position by four bytes.

  The four-byte unsigned integer to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.CLSCompliant(false)
  System.Void ``

  BinaryWriter stores this data type in little endian format.

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes an eight-byte unsigned integer to the current stream and advances the stream position by eight bytes.

  The eight-byte unsigned integer to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a region of a byte array to the current stream.

  A byte array containing the data to write. The starting point in at which to begin writing. The number of bytes to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void `` `` ``

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a section of a character array to the current stream, and advances the current position of the stream in accordance with the Encoding used and perhaps the specific characters being written to the stream.

  A character array containing the data to write. The starting point in from which to begin writing. The number of characters to write.
- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Void ``

  The integer of the parameter is written out seven bits at a time, starting with the seven least-significant bits. The high bit of a byte indicates whether there are more bytes to be written after this one.

  If will fit in seven bits, it takes only one byte of space. If will not fit in seven bits, the high bit is set on the first byte and written out. is then shifted by seven bits and the next byte is written. This process is repeated until the entire integer has been written.

  For a list of common I/O tasks, see Common I/O Tasks.

  Writes a 32-bit integer in a compressed format.

  The 32-bit integer to be written.