How do I use WriteByte? The below code will not work, coming up with both a CS1502 error, and a CS1502 error at the "stream.WriteByte(totalSeasons);" line. It's frustrating because I am incredibly close to finishing this program.
Essentially, my problem is that I need to write binary data to a file on the click of a button. I can just write this for example: stream.WriteByte(0xCD); The problem is that I need to allow the user to type in the data they want to be written into a textbox, and then on the click of a button the data will be converted from decimal to hex, and then put in. I think I've figured the conversion part out, but I can't edit the binary with the data because it seems that WriteByte can only write Hex values like 0xCD, and there seems to be no way to store the hex value and still write it. I've tried stream.WriteByte(ByteName); but that comes with the errors described above.
void BtnTotalSeasonsClick(object sender, EventArgs e)
{
using (var stream = new FileStream(drvFile, FileMode.Open, FileAccess.ReadWrite))
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
Byte[] totalSeasons = enc.GetBytes(txtTotalSeasons.Text);
stream.Position = 4;
stream.WriteByte(totalSeasons);
}
}