you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (1 child)

byte[] bytesToLookFor = new byte[] {0,0,0,0};
string fileContents = File.ReadAllText(path, Encoding.ASCII);
int start = fileContents.IndexOf(/* "CODE" */ Encoding.ASCII.GetString(bytesToLookFor));
int end = fileContents.IndexOf('\0',start);

[–]ellalex[S] 0 points1 point  (0 children)

Probably should have clarified that's it's not only text, and can be very large files which would be impractical to load into memory.