Hi I don’t fully understand how the byte array is being filled within the load method:
public void Load(string saveFile)
{
string path = GetPathFromSaveFile(saveFile);
print($"Loading from {GetPathFromSaveFile(saveFile)}");
using (FileStream stream = File.Open(path, FileMode.Open))
{
byte[] byteBuffer = new byte[stream.Length] ;
stream.Read(byteBuffer, 0, byteBuffer.Length);
print(Encoding.UTF8.GetString(byteBuffer));
}
}
More specifically the lines:
byte[] byteBuffer = new byte[stream.Length] ;
From my understanding, the stream.length is setting the size of the array, but isn’t filling it with the bytes from the file, is it?
This is somehow happening on the next line:
stream.Read(byteBuffer, 0, byteBuffer.Length);
How is this happening, is it changing the array when it’s passed into the read method?