Instead of converting each value to a byte array, you can use BinaryWriter
to write the values to a file stream.
Example:
using (BinaryWriter writer = new BinaryWriter(fileStream)) {
writer.Write(1);
writer.Write(1.0);
writer.Write(true);
writer.Write("Hello");
}
Guffa
a source
to share