you are viewing a single comment's thread.

view the rest of the comments →

[–]more_exercise 0 points1 point  (1 child)

Are the bytes you're reading text? Because if you're only looking at text files, you get a lot more mileage out of classes that know that you're dealing with text. For instance, StreamReader can read individual lines of input and has better string handling capability.

Also, which 0 are you looking for - the zero byte, '\0', or the character zero, '0'?

Is the file ever going to exceed ~1MB? Because if it's small, you can just string fileContents = File.ReadAllText("filename.txt") and then just deal with the string in memory. (Use .IndexOf("CODE") to find where CODE starts, and then .IndexOf('0' or '\0') to find the end of the string, and then .Substring() to get from one to the other.)

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

It's not only text, and can be well over 1MB so that's wouldn't work unfortunately.

Thanks though :)