I'm having trouble and I think it's because I'm doing something wrong with BinaryWriter. In essence, I'm trying to write over an existing group of images and text strings in a file using BinaryWriter. The code functions and there's no complaints, errors or anything to tell me it's not working as intended. But when it finishes and I re-load the now supposedly edited file, it's showing the old images and text, as if nothing was saved to the file. This is the bit of code that I think should be doing it but isn't doing it.
const Int32 SAVE_OFFSET = 0x457000;
const Int32 SAVE_SIZE = 0x43A929;
bw = new BinaryWriter(File.Open(saveFile, FileMode.Open, FileAccess.ReadWrite));
bw.BaseStream.Seek(SAVE_OFFSET, SeekOrigin.Begin);
var save = File.ReadAllBytes(datFile);
if (save.Length != SAVE_SIZE)
{
MessageBox.Show("File is not the expected size!\nExpected: " + SAVE_SIZE + "\nActual: " + save.Length);
}
bw.Write(File.ReadAllBytes(datFile), 0, SAVE_SIZE);
bw.Close();
Everything seems to be working but it just doesn't save to the file. Any ideas?