Thanks for reply and sorry if something isnt clear as im just starting c# self learning
Yes i need to read 4 individual bytes from a file and display them in one textbox.
File is binary .bin extension, file size not larger than 512 bytes.
to be clear and with all details file has line
0x1E0 00 00 00 01 09 00 0F BB 36 30 35 39 FE 32 A5 53
bytes needed 36 30 35 39 (0x1E8, 0x1E9, 0x1EA, 0x1EB)
in order 36 35 30 39 (0x1E8, 0x1EA, 0x1E9 0x1EB)
and displayed into text box as 6509
Have tried to read as much info as i can for filestream, tried to make some but nothing worked and i cant find any code sample how to get it displayed into text box, now starting from 0 again and thats why im asking for some help, example etc
For now i have code using binary reader which works with some bugs but works
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == DialogResult.OK)
{
button2.Enabled = true;
path = ofd.FileName;
}
}
private void button2_Click(object sender, EventArgs e)
{
BinaryReader br = new BinaryReader(File.OpenRead(path));
br.BaseStream.Position = 0x234;
foreach (char myChar in br.ReadChars(4)) textBox1.Text += myChar;
br.BaseStream.Position = 0x1CE;
foreach (char myChar in br.ReadChars(17)) textBox2.Text += myChar;
br.BaseStream.Position = 0xA0;
foreach (char myChar in br.ReadChars(2)) textBox3.Text += myChar;
br.BaseStream.Position = 0x22;
foreach (char myChar in br.ReadChars(3)) textBox5.Text += myChar;
br.BaseStream.Position = 0x1CE;
foreach (char myChar in br.ReadChars(7)) textBox4.Text += myChar;
{
if (textBox4.Text == "W0L0AHL")
{
MessageBox.Show("H IPC");
}
else if (textBox4.Text == "W0L0AHM")
{
MessageBox.Show("B IPC");
}
{
if (textBox3.Text == "WC")
{
MessageBox.Show("PETROL");
}
}
}
}
}
}
have noticed that all works fine but when button2 is clicked again it duplicates all info in textboxies, tried br.dispose but it doesnt work or i incorectly used it