AMT Help Files

FileBinaryStream Interface

The Binary Stream object (IFileBinaryStream) is returned by the CreateBinaryFile and OpenBinaryFile functions of the ComScript FileObject. Through this object the data in the file can be accessed as binary data with the use of the functions described below.

Functions



Name
Return Type
Parameters
Description
Name
Type
Close
Boolean
---

Closes the current file. Returns True when successful.
Read
Array of Bytes
Offset
Integer64 
Reads the number of bytes specified by Count from the stream starting at the position in the stream specified by Offset.
Count
Integer
  
Write
Boolean
Buffer
Array of Bytes
Writes the number of bytes specified in Count from the array of bytes Buffer to the stream. Returns True when successful and false when failed.
When flush is set to True the pending information in the stream will be written to the file directly and the internal stream buffers will be cleared.
When Append is set to True the data will be appended to the end of the stream.
Count
Integer
Flush
Boolean
Append
Boolean


Example


PowerShell


#See ComScript Connection Interface
... 
$ComScr.Connect()

#Create an object of the FileObject Interface to be able to handle files.

$AmtFile = $ComScr.CreateFileObject()


#Open a binary file, this creates an object of the FileBinaryStream Interface to be able to read & write the binary file.

$AmtBinaryEnd = $AmtFile.OpenBinaryFile("D:\Files\Ending.raw", 4)

$EndingBytes = $AmtBinaryEnd.Read(0, 102400)

[void]$AmtBinaryEnd.Close()


#Open another binary file, creating a second object of the FileBinaryStream Interface.

$AmtBinaryFile = $AmtFile.OpenBinaryFile("D:\Files\Main.raw", 1)

[void]$AmtBinaryFile.Write($EndingBytes, 102400, $true, $true)


#Close all the binary files

[void]$AmtFile.CloseAllFiles()


# Finally release the variables and clean up the session.
$ComScr.Dispose()