0

I have an issue where my C# code wasn't able to change a hex value in the 13th position.

See the screenshot from HxD Hex editor for further detail

This is C# my code:

private void button1_Click(object sender, EventArgs e)
{
    OpenFileDialog openFileDialog = new OpenFileDialog();
    if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        string fileName = openFileDialog.FileName;
        textBox1.Text = fileName;
    }
}

private void button2_Click(object sender, EventArgs e)
{
    string fileName = textBox1.Text;
    using (var stream = new FileStream(fileName, FileMode.Open, FileAccess.ReadWrite))
    {
        stream.Position = 13;
        stream.WriteByte(0x00);
    }
}
0

1 Answer 1

1

you have stream.Position = 13; (13 is in decimal) Your picture is pointing to 13 hex (19 in decimal) so you'll need stream.Position = 0x13

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.