0

How can I read the last x bytes from a binary file or is there a way to determine how many bytes are in the file?

I could then at least try something like:

File.ReadAllBytes(file).Skip(Size-25).Take(25).ToArray();
John Doe
  • 3,053
  • 17
  • 48
  • 75
  • 1
    have you considered looking at a `Stream`? – Daniel A. White Feb 24 '17 at 13:55
  • Of course there is. Literally the first result on a search will show it. And please don't write something like that. https://msdn.microsoft.com/en-us/library/system.io.fileinfo.length(v=vs.110).aspx – Sami Kuhmonen Feb 24 '17 at 13:56
  • Move the read pointer to the end minus x and then perform the read. You know the amount of bytes by asking the SO. – dcg Feb 24 '17 at 13:56
  • Possible duplicate of https://stackoverflow.com/questions/4368857/read-from-a-file-starting-at-the-end-similar-to-tail – sgmoore Feb 24 '17 at 13:58

0 Answers0