Class FileAssistant
A utility class for reading/writing from/to a File.
Inheritance
Namespace: FM.LiveSwitch
Assembly: FM.LiveSwitch.dll
Syntax
public class FileAssistant : object
Constructors
FileAssistant(FileStream)
Initializes a new instance of the FileAssistant class.
Declaration
public FileAssistant(FileStream file)
Parameters
Type | Name | Description |
---|---|---|
FileStream | file | The file. |
Properties
File
Gets the file.
Declaration
public FileStream File { get; }
Property Value
Type | Description |
---|---|
FileStream |
LittleEndian
Gets or sets whether to read/write using little-endian ordering.
Declaration
public bool LittleEndian { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
Read(Int32)
Reads a value from a File.
Declaration
public byte[] Read(int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | length | The number of bytes to read. |
Returns
Type | Description |
---|---|
System.Byte[] |
Read16()
Converts a 16-bit network representation to an integer.
Declaration
public int Read16()
Returns
Type | Description |
---|---|
System.Int32 |
Read24()
Converts a 24-bit network representation to an integer.
Declaration
public int Read24()
Returns
Type | Description |
---|---|
System.Int32 |
Read32()
Converts a 32-bit network representation to an integer.
Declaration
public long Read32()
Returns
Type | Description |
---|---|
System.Int64 |
Read40()
Converts a 40-bit network representation to an integer.
Declaration
public long Read40()
Returns
Type | Description |
---|---|
System.Int64 |
Read48()
Converts a 48-bit network representation to an integer.
Declaration
public long Read48()
Returns
Type | Description |
---|---|
System.Int64 |
Read56()
Converts a 56-bit network representation to an integer.
Declaration
public long Read56()
Returns
Type | Description |
---|---|
System.Int64 |
Read64()
Converts a 64-bit network representation to an integer.
Declaration
public long Read64()
Returns
Type | Description |
---|---|
System.Int64 |
Read8()
Converts an 8-bit network representation to an integer.
Declaration
public int Read8()
Returns
Type | Description |
---|---|
System.Int32 |
ReadAllBytes(String)
Reads all the bytes of a file into a byte array.
Declaration
public static byte[] ReadAllBytes(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The filepath to the file to read. |
Returns
Type | Description |
---|---|
System.Byte[] |
ReadOpaque16()
Reads a 16-bit-length opaque value from a File.
Declaration
public byte[] ReadOpaque16()
Returns
Type | Description |
---|---|
System.Byte[] |
ReadOpaque24()
Reads a 24-bit-length opaque value from a File.
Declaration
public byte[] ReadOpaque24()
Returns
Type | Description |
---|---|
System.Byte[] |
ReadOpaque32()
Reads a 32-bit-length opaque value from a File.
Declaration
public byte[] ReadOpaque32()
Returns
Type | Description |
---|---|
System.Byte[] |
ReadOpaque8()
Reads an 8-bit-length opaque value from a File.
Declaration
public byte[] ReadOpaque8()
Returns
Type | Description |
---|---|
System.Byte[] |
Write(Byte[])
Adds a value to a File.
Declaration
public void Write(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Write(Byte[], Int32, Int32)
Adds a value to a File.
Declaration
public void Write(byte[] value, int offset, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
System.Int32 | offset | The offset. |
System.Int32 | length | The length. |
Write16(Int32)
Adds a 16-bit value to a File.
Declaration
public void Write16(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value. |
Write16To(Int32, Int32)
Adds a 16-bit value to a File.
Declaration
public void Write16To(int location, int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Int32 | value | The value. |
Write24(Int32)
Adds a 24-bit value to a File.
Declaration
public void Write24(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value. |
Write24To(Int32, Int32)
Adds a 24-bit value to a File.
Declaration
public void Write24To(int location, int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Int32 | value | The value. |
Write32(Int64)
Adds a 32-bit value to a File.
Declaration
public void Write32(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value. |
Write32To(Int32, Int64)
Adds a 32-bit value to a File.
Declaration
public void Write32To(int location, long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Int64 | value | The value. |
Write40(Int64)
Adds a 40-bit value to a File.
Declaration
public void Write40(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value. |
Write40To(Int32, Int64)
Adds a 40-bit value to a File.
Declaration
public void Write40To(int location, long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Int64 | value | The value. |
Write48(Int64)
Adds a 48-bit value to a File.
Declaration
public void Write48(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value. |
Write48To(Int32, Int64)
Adds a 48-bit value to a File.
Declaration
public void Write48To(int location, long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Int64 | value | The value. |
Write56(Int64)
Adds a 56-bit value to a File.
Declaration
public void Write56(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value. |
Write56To(Int32, Int64)
Adds a 56-bit value to a File.
Declaration
public void Write56To(int location, long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Int64 | value | The value. |
Write64(Int64)
Adds a 64-bit value to a File.
Declaration
public void Write64(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value. |
Write64To(Int32, Int64)
Adds a 64-bit value to a File.
Declaration
public void Write64To(int location, long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Int64 | value | The value. |
Write8(Int32)
Adds an 8-bit value to a File.
Declaration
public void Write8(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | The value. |
Write8To(Int32, Int32)
Adds an 8-bit value to a File.
Declaration
public void Write8To(int location, int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Int32 | value | The value. |
WriteOpaque16(Byte[])
Adds a 16-bit-length opaque value to a File.
Declaration
public void WriteOpaque16(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
WriteOpaque16To(Int32, Byte[])
Adds a 16-bit-length opaque value to a File.
Declaration
public void WriteOpaque16To(int location, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | value | The value. |
WriteOpaque24(Byte[])
Adds a 24-bit-length opaque value to a File.
Declaration
public void WriteOpaque24(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
WriteOpaque24To(Int32, Byte[])
Adds a 24-bit-length opaque value to a File.
Declaration
public void WriteOpaque24To(int location, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | value | The value. |
WriteOpaque32(Byte[])
Adds a 32-bit-length opaque value to a File.
Declaration
public void WriteOpaque32(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
WriteOpaque32To(Int32, Byte[])
Adds a 32-bit-length opaque value to a File.
Declaration
public void WriteOpaque32To(int location, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | value | The value. |
WriteOpaque40(Byte[])
Adds a 40-bit-length opaque value to a File.
Declaration
public void WriteOpaque40(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
WriteOpaque40To(Int32, Byte[])
Adds a 40-bit-length opaque value to a File.
Declaration
public void WriteOpaque40To(int location, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | value | The value. |
WriteOpaque48(Byte[])
Adds a 48-bit-length opaque value to a File.
Declaration
public void WriteOpaque48(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
WriteOpaque48To(Int32, Byte[])
Adds a 48-bit-length opaque value to a File.
Declaration
public void WriteOpaque48To(int location, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | value | The value. |
WriteOpaque56(Byte[])
Adds a 56-bit-length opaque value to a File.
Declaration
public void WriteOpaque56(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
WriteOpaque56To(Int32, Byte[])
Adds a 56-bit-length opaque value to a File.
Declaration
public void WriteOpaque56To(int location, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | value | The value. |
WriteOpaque64(Byte[])
Adds a 64-bit-length opaque value to a File.
Declaration
public void WriteOpaque64(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
WriteOpaque64To(Int32, Byte[])
Adds a 64-bit-length opaque value to a File.
Declaration
public void WriteOpaque64To(int location, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | value | The value. |
WriteOpaque8(Byte[])
Adds an 8-bit-length opaque value to a File.
Declaration
public void WriteOpaque8(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
WriteOpaque8To(Int32, Byte[])
Adds an 8-bit-length opaque value to a File.
Declaration
public void WriteOpaque8To(int location, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | value | The value. |
WriteTo(Int32, Byte[])
Adds a value to a File.
Declaration
public void WriteTo(int location, byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | location | The location to write to. |
System.Byte[] | value | The value. |