Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- internal class BinaryFileReader
- {
- private static int sum1;
- private static int sum2;
- public BinaryFileReader(string path)
- {
- using FileStream fileStream = File.Open(path, FileMode.Open, FileAccess.Read);
- using BinaryReader binaryReader = new BinaryReader(fileStream);
- while (true)
- {
- try
- {
- sum1 += binaryReader.ReadInt16();
- }
- catch (Exception)
- {
- break;
- }
- }
- fileStream.Seek(0, SeekOrigin.Begin);
- while (true)
- {
- try
- {
- sum2 += binaryReader.ReadInt32();
- }
- catch (Exception)
- {
- break;
- }
- }
- }
- public int GetDifference()
- {
- return Math.Abs(sum1 - sum2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment