Hex search and replace

Imperio Tuga 41 Reputation points
2021-10-13T09:55:09.197+00:00

Hello, im trying to do an bytes replacer in a .bin file.

I need to search this value in file
08 01 10 05 30 08 81 22

And replace it with
90 81 19 40 00 78 41 00

I've used fileContents = fileContents.Replace(Convert.ToChar(&H08) but seems my file gets weird.
Thanks

Developer technologies | VB
0 comments No comments
{count} votes

Answer accepted by question author
  1. Castorix31 91,281 Reputation points
    2021-10-13T10:06:36.697+00:00

    Use File.ReadAllBytes / File.WriteAllBytes

    You can find samples on Google, like :

    How to Find and Replace Hexadecimal Characters in a text File Using VB.net

    Find & replace hex values in a .dll file using C#

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Imperio Tuga 41 Reputation points
    2021-10-13T11:21:41.64+00:00

    Thanks Castorix31

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.