File.ReadBytes
method · File · cAlgo.API Since 5.7
DesktopCLICloud
Reads a sequence of bytes from the file.
Environment behaviour
Cloud — not supported. Exists returns false; reads return empty string/array; writes and appends silently do nothing. No exception.
Definition
byte[] ReadBytes(int offset, int count)
file.ReadBytes(offset: int, count: int) -> list[int]
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
offset | int | int | File byte offset |
count | int | int | Count of bytes to read |
Returns byte[] — byte[]
Examples
protected override void OnStart()
{
var header = DataFile.ReadBytes(0, 16);
Print("File header: {0}", Encoding.UTF8.GetString(header));
}
from System.Text import Encoding
header = api.DataFile.ReadBytes(0, 16)
api.Print(f"File header: {Encoding.UTF8.GetString(header)}")
{
"Parameters": [
{
"Name": "DataFile",
"DisplayName": "Data File",
"Type": "File"
}
]
}