My C# is very rusty (no pun intended) but I would guess the core of the program could be something like
File.ReadAllBytes("file.bin").Where(x => x == '1').Count()
My C# is very rusty (no pun intended) but I would guess the core of the program could be something like
And nitpick: the code you gave has a bug. file.Read can return less than 4096. If so, you should only loop over the part of the buffer it filled.