<div class="meta" robots="noindex">

</div>

Class

# Xojo.IO.BinaryStream

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2020r2. Please use `BinaryStream</api/files/binarystream>` as a replacement.

</div>

## Description

The BinaryStream class is an input/output mechanism for reading and writing arbitrary binary data. It can be used with MemoryBlocks and FolderItems.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                              | Type                                              | Read-Only | Shared |
|---------------------------------------------------|---------------------------------------------------|-----------|--------|
| `IsClosed<xojo.io.binarystream.isclosed>`         | `Boolean</api/data_types/boolean>`                | ✓         |        |
| `Length<xojo.io.binarystream.length>`             | `UInt64</api/data_types/additional_types/uint64>` |           |        |
| `LittleEndian<xojo.io.binarystream.littleendian>` | `Boolean</api/data_types/boolean>`                |           |        |
| `Position<xojo.io.binarystream.position>`         | `UInt64</api/data_types/additional_types/uint64>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                                | Parameters                                                                                                    | Returns                                           | Shared |
|-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------|--------|
| `Close<xojo.io.binarystream.close>`                 |                                                                                                               |                                                   |        |
| `Constructor<xojo.io.binarystream.constructor0>`    | mb As `MemoryBlock</api/language/memoryblock>`                                                                |                                                   |        |
| `Create<xojo.io.binarystream.create>`               | file As `FolderItem</api/files/folderitem>`                                                                   | `BinaryStream</api/files/binarystream>`           |        |
| `EOF<xojo.io.binarystream.eof>`                     |                                                                                                               | `Boolean</api/data_types/boolean>`                |        |
| `Flush<xojo.io.binarystream.flush>`                 |                                                                                                               |                                                   |        |
| `FromHandle<xojo.io.binarystream.fromhandle>`       | handle As `Ptr</api/data_types/additional_types/ptr>`, type As Xojo.IO.HandleTypes                            | `BinaryStream</api/files/binarystream>`           |        |
| `Handle<xojo.io.binarystream.handle>`               | type As Xojo.IO.HandleTypes                                                                                   | `Ptr</api/data_types/additional_types/ptr>`       |        |
| `Open<xojo.io.binarystream.open>`                   | file As `FolderItem</api/files/folderitem>`, mode As `LockModes<xojo.io.binarystream.lockmodes>`              | `BinaryStream</api/files/binarystream>`           |        |
| `Read<xojo.io.binarystream.read>`                   | count As `Integer</api/data_types/integer>`                                                                   | `MemoryBlock</api/language/memoryblock>`          |        |
| `ReadBoolean<xojo.io.binarystream.readboolean>`     |                                                                                                               | `Boolean</api/data_types/boolean>`                |        |
| `ReadCurrency<xojo.io.binarystream.readcurrency>`   |                                                                                                               | `Currency</api/data_types/currency>`              |        |
| `ReadDouble<xojo.io.binarystream.readdouble>`       |                                                                                                               | `Double</api/data_types/double>`                  |        |
| `ReadInt16<xojo.io.binarystream.readint16>`         |                                                                                                               | `Int16</api/data_types/additional_types/int16>`   |        |
| `ReadInt32<xojo.io.binarystream.readint32>`         |                                                                                                               | `Int32</api/data_types/additional_types/int32>`   |        |
| `ReadInt64<xojo.io.binarystream.readint64>`         |                                                                                                               | `Int64</api/data_types/additional_types/int64>`   |        |
| `ReadInt8<xojo.io.binarystream.readint8>`           |                                                                                                               | `Int8</api/data_types/additional_types/int8>`     |        |
| `ReadSingle<xojo.io.binarystream.readsingle>`       |                                                                                                               | `Single</api/data_types/single>`                  |        |
| `ReadText<xojo.io.binarystream.readtext>`           | count As `Integer</api/data_types/integer>`, encoding As `TextEncoding</api/text/encoding_text/textencoding>` | `String</api/data_types/string>`                  |        |
| `ReadUInt16<xojo.io.binarystream.readuint16>`       |                                                                                                               | `UInt16</api/data_types/additional_types/uint16>` |        |
| `ReadUInt32<xojo.io.binarystream.readuint32>`       |                                                                                                               | `UInt32</api/data_types/additional_types/uint32>` |        |
| `ReadUInt64<xojo.io.binarystream.readuint64>`       |                                                                                                               | `UInt64</api/data_types/additional_types/uint64>` |        |
| `ReadUInt8<xojo.io.binarystream.readuint8>`         |                                                                                                               | `UInt8</api/data_types/additional_types/uint8>`   |        |
| `Write<xojo.io.binarystream.write>`                 | block As `MemoryBlock</api/language/memoryblock>`                                                             |                                                   |        |
| `WriteBoolean<xojo.io.binarystream.writeboolean>`   | value As `Boolean</api/data_types/boolean>`                                                                   |                                                   |        |
| `WriteCurrency<xojo.io.binarystream.writecurrency>` | value As `Currency</api/data_types/currency>`                                                                 |                                                   |        |
| `WriteDouble<xojo.io.binarystream.writedouble>`     | value As `Double</api/data_types/double>`                                                                     |                                                   |        |
| `WriteInt16<xojo.io.binarystream.writeint16>`       | value As `Int16</api/data_types/additional_types/int16>`                                                      |                                                   |        |
| `WriteInt32<xojo.io.binarystream.writeint32>`       | value As `Int32</api/data_types/additional_types/int32>`                                                      |                                                   |        |
| `WriteInt64<xojo.io.binarystream.writeint64>`       | value As `Int64</api/data_types/additional_types/int64>`                                                      |                                                   |        |
| `WriteInt8<xojo.io.binarystream.writeint8>`         | value As `Int8</api/data_types/additional_types/int8>`                                                        |                                                   |        |
| `WriteSingle<xojo.io.binarystream.writesingle>`     | value As `Single</api/data_types/single>`                                                                     |                                                   |        |
| `WriteText<xojo.io.binarystream.writetext>`         | value As `String</api/data_types/string>`, encoding As `TextEncoding</api/text/encoding_text/textencoding>`   |                                                   |        |
| `WriteUInt16<xojo.io.binarystream.writeuint16>`     | value As `UInt16</api/data_types/additional_types/uint16>`                                                    |                                                   |        |
| `WriteUInt32<xojo.io.binarystream.writeuint32>`     | value As `UInt32</api/data_types/additional_types/uint32>`                                                    |                                                   |        |
| `WriteUInt64<xojo.io.binarystream.writeuint64>`     | value As `UInt64</api/data_types/additional_types/uint64>`                                                    |                                                   |        |
| `WriteUInt8<xojo.io.binarystream.writeuint8>`       | value As `UInt8</api/data_types/additional_types/uint8>`                                                      |                                                   |        |

## Enumerations

<div id="xojo.io.binarystream.lockmodes">

<div class="rst-class">

forsearch

</div>

</div>

Xojo.IO.BinaryStream.LockModes

### LockModes

The type of locking modes for the binary stream. (Read, Write, ReadWrite, Exclusive)

| Enum      | Description                                       |
|-----------|---------------------------------------------------|
| Read      | Read access.                                      |
| Write     | Write access.                                     |
| ReadWrite | Read and write access.                            |
| Exclusive | Exclusive lock; nothing else can access the file. |

## Property descriptions

<div id="xojo.io.binarystream.isclosed">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.IsClosed

**IsClosed** As `Boolean</api/data_types/boolean>`

Determines if the binary stream has been closed.

This property is read-only.

<div id="xojo.io.binarystream.length">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Length

**Length** As `UInt64</api/data_types/additional_types/uint64>`

Gets or sets the length of the file in bytes. If you set the Length property to a value smaller than its current value, it truncates the file. If the BinaryStream is backed by a MemoryBlock, it returns MemoryBlock.Size. Raises an exception if setting the Length of a BinaryStream backed by a MemoryBlock with unknown size.

<div id="xojo.io.binarystream.littleendian">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.LittleEndian

**LittleEndian** As `Boolean</api/data_types/boolean>`

Gets or sets the byte order when reading or writing to a BinaryStream. A value of True sets the byte order to little endian.

<div id="xojo.io.binarystream.position">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Position

**Position** As `UInt64</api/data_types/additional_types/uint64>`

Gets or sets the current position within the BinaryStream. The first position is numbered zero. To move the position to the end of the stream, set the Position to Length.

To append to the end of a file, set the Position to the Length and then Write.

## Method descriptions

<div id="xojo.io.binarystream.close">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Close

**Close**

Closes an existing BinaryStream. Raises an exception if the stream is already closed.

<div id="xojo.io.binarystream.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Constructor

**Constructor**(mb As `MemoryBlock</api/language/memoryblock>`)

<div class="note">

<div class="title">

Note

</div>

`Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.

</div>

Creates a BinaryStream from a MemoryBlock.

A BinaryStream created using a MemoryBlock will automatically re-size the MemoryBlock as needed to contain any additional data written to the stream.

Create binary data from an Image in the iOS project:

``` xojo
' MyImage is an iOSImage in the project
Var binaryData As New BinaryStream(MyImage.ToData("public.PNG"))
```

<div id="xojo.io.binarystream.create">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Create

**Create**(file As `FolderItem</api/files/folderitem>`) As `BinaryStream</api/files/binarystream>`

Creates a new BinaryStream, bound to the passed File. Raises a RuntimeException if File is Nil, does not exist, is not accessible or another error occurs.

``` xojo
Using Xojo.IO
Using Xojo.Core

Var f As FolderItem = SpecialFolder.Documents.Child("MyFile.data")
Var bStream As BinaryStream
bStream = BinaryStream.Create(f)

Var data As MemoryBlock
Var t As Text = "Text for the binary file."
data = TextEncoding.UTF8.ConvertTextToData(t)
bStream.Write(data)
bStream.Close
```

<div id="xojo.io.binarystream.eof">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.EOF

**EOF** As `Boolean</api/data_types/boolean>`

Returns True if the BinaryStream position = the file length. If the stream is closed this function always returns True.

<div id="xojo.io.binarystream.flush">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Flush

**Flush**

Immediately sends the contents of internal write buffers to disk or to the output stream.

<div id="xojo.io.binarystream.fromhandle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.FromHandle

**FromHandle**(handle As `Ptr</api/data_types/additional_types/ptr>`, type As Xojo.IO.HandleTypes) As `BinaryStream</api/files/binarystream>`

Creates a new BinaryStream from an OS handle.

<div id="xojo.io.binarystream.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Handle

**Handle**(type As Xojo.IO.HandleTypes) As `Ptr</api/data_types/additional_types/ptr>`

Given a handle type, gets a handle to the current stream . File Descriptor, File Pointer, or a Windows32 OS handle.

<div id="xojo.io.binarystream.open">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Open

**Open**(file As `FolderItem</api/files/folderitem>`, mode As `LockModes<xojo.io.binarystream.lockmodes>`) As `BinaryStream</api/files/binarystream>`

Opens the passed FolderItem as a binary stream with the specified lock mode. If an error occurs, an IOException is raised.

Read all the data from a file:

``` xojo
Using Xojo.Core
Using Xojo.IO
Var f As FolderItem = SpecialFolder.Documents.Child("MyFile.data")
Var bStream As BinaryStream
bStream = BinaryStream.Open(f, BinaryStream.LockModes.Read)

Var data As MemoryBlock
data = bStream.Read(bStream.Length)

bStream.Close
```

To append data to a binary file, open the file in read/write mode and then call the Write method once you have reached EOF:

``` xojo
Using Xojo.IO
Using Xojo.Core

Var f As FolderItem = SpecialFolder.Documents.Child("MyFile.data")
Var bStream As BinaryStream
bStream = BinaryStream.Open(f, BinaryStream.LockModes.ReadWrite)

Var data As MemoryBlock
data = bStream.Read(bStream.Length) ' reached EOF

Var mb As MemoryBlock
Var t As Text = "Text to append"
mb = TextEncoding.UTF8.ConvertTextToData(t)
bStream.Write(mb) ' data is appended to the BinaryStream
bStream.Close
```

<div id="xojo.io.binarystream.read">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Read

**Read**(count As `Integer</api/data_types/integer>`) As `MemoryBlock</api/language/memoryblock>`

Reads the specified number of bytes. Raises an exception if the file is not readable.

Read 1K into a MemoryBlock:

``` xojo
Var data As MemoryBlock
data = bStream.Read(1024)
```

Read the entire file into a MemoryBlock:

``` xojo
Var data As MemoryBlock
data = bStream.Read(bStream.Length)
```

<div id="xojo.io.binarystream.readboolean">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadBoolean

**ReadBoolean** As `Boolean</api/data_types/boolean>`

Reads a Boolean from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readcurrency">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadCurrency

**ReadCurrency** As `Currency</api/data_types/currency>`

Xojo.IO.BinaryStream

<div id="xojo.io.binarystream.readdouble">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadDouble

**ReadDouble** As `Double</api/data_types/double>`

Reads a Double from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readint16">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadInt16

**ReadInt16** As `Int16</api/data_types/additional_types/int16>`

Reads an Int16 from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readint32">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadInt32

**ReadInt32** As `Int32</api/data_types/additional_types/int32>`

Reads an Int32 from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readint64">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadInt64

**ReadInt64** As `Int64</api/data_types/additional_types/int64>`

Reads an Int64 from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readint8">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadInt8

**ReadInt8** As `Int8</api/data_types/additional_types/int8>`

Reads an Int8 from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readsingle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadSingle

**ReadSingle** As `Single</api/data_types/single>`

Reads a Single from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readtext">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadText

**ReadText**(count As `Integer</api/data_types/integer>`, encoding As `TextEncoding</api/text/encoding_text/textencoding>`) As `String</api/data_types/string>`

Reads the next count bytes from the stream. Raises an exception if the file is not readable or if encoding is Nil.

<div id="xojo.io.binarystream.readuint16">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadUInt16

**ReadUInt16** As `UInt16</api/data_types/additional_types/uint16>`

Reads a UInt16 from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readuint32">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadUInt32

**ReadUInt32** As `UInt32</api/data_types/additional_types/uint32>`

Reads a UInt32 from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readuint64">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadUInt64

**ReadUInt64** As `UInt64</api/data_types/additional_types/uint64>`

Reads a UInt64 from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.readuint8">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.ReadUInt8

**ReadUInt8** As `UInt8</api/data_types/additional_types/uint8>`

Reads a UInt8 from the stream. Raises an exception if the file is not readable.

<div id="xojo.io.binarystream.write">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.Write

**Write**(block As `MemoryBlock</api/language/memoryblock>`)

Writes the bytes in the memoryblock. Raises an exception if the stream is not writable or the MemoryBlock has an unknown size.

<div id="xojo.io.binarystream.writeboolean">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteBoolean

**WriteBoolean**(value As `Boolean</api/data_types/boolean>`)

Writes a Boolean to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writecurrency">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteCurrency

**WriteCurrency**(value As `Currency</api/data_types/currency>`)

Writes a Currency to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writedouble">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteDouble

**WriteDouble**(value As `Double</api/data_types/double>`)

Writes a Double to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writeint16">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteInt16

**WriteInt16**(value As `Int16</api/data_types/additional_types/int16>`)

Writes an Int16 to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writeint32">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteInt32

**WriteInt32**(value As `Int32</api/data_types/additional_types/int32>`)

Writes an Int32 to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writeint64">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteInt64

**WriteInt64**(value As `Int64</api/data_types/additional_types/int64>`)

Writes an Int64 to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writeint8">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteInt8

**WriteInt8**(value As `Int8</api/data_types/additional_types/int8>`)

Writes an Int8 to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writesingle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteSingle

**WriteSingle**(value As `Single</api/data_types/single>`)

Writes a Single to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writetext">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteText

**WriteText**(value As `String</api/data_types/string>`, encoding As `TextEncoding</api/text/encoding_text/textencoding>`)

Writes the bytes in the Text. Raises an exception if the stream is not writable, or encoding is Nil.

<div id="xojo.io.binarystream.writeuint16">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteUInt16

**WriteUInt16**(value As `UInt16</api/data_types/additional_types/uint16>`)

Writes a UInt16 to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writeuint32">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteUInt32

**WriteUInt32**(value As `UInt32</api/data_types/additional_types/uint32>`)

Writes a UInt32 to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writeuint64">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteUInt64

**WriteUInt64**(value As `UInt64</api/data_types/additional_types/uint64>`)

Writes a UInt64 to the stream. Raises an exception if the stream is not writable.

<div id="xojo.io.binarystream.writeuint8">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Xojo.IO.BinaryStream.WriteUInt8

**WriteUInt8**(value As `UInt8</api/data_types/additional_types/uint8>`)

Writes a UInt8 to the stream. Raises an exception if the stream is not writable.

## Notes

The Read/Write methods raise an exception when reading or writing past the end of the stream. File IO prevents thread switching.

## Sample code

Load an image that is copied to an iOS app using a Copy Files Build Step:

``` xojo
Var f As FolderItem = SpecialFolder.GetResource("MyImage.JPG")

Var b As BinaryStream
b = BinaryStream.Open(f, BinaryStream.LockModes.Read)

Var mb As New MemoryBlock(b.Read(b.Length))

b.Close

Var image As iOSImage
image = Image.FromData(mb)

ImageView1.Image = image
```

## Compatibility

All project types on all supported operating systems.

## See also

`Object</api/data_types/additional_types/object>` parent class; `FolderItem</api/files/folderitem>`, `MemoryBlock</api/language/memoryblock>` classes
