I am trying to edit the hex code of a file. The code in C# needs to find either the decoded text i.e., 1004
or the corresponding hex 31 30 30 34
and replace with string 2113
or either the corresponding hex 32 31 31 33
I have tried to edit the string directly using:-
string test = File.ReadAllText("tram.png");
Regex id = new Regex("1004");
string idre = id.Replace(test, "2113", 1);
File.WriteAllText("tram.png", idre);
Also tried Byte
method
Byte[] test = File.ReadAllBytes("tram.png");
Byte[] id = new Regex("1004");
Byte[] idre = id.Replace(test, "2113", 1);
File.WriteAllBytes("tram.png", idre);
It says 'byte[]' does not contain a definition for 'Replace' and Cannot implicitly convert type 'System.Text.RegularExpressions.Regex' to 'byte[]'
Can you tell me what am I doing wrong please?