Esempio n. 1
0
        private long CalculateFileCrc(string filePath)
        {
            FileStream fs = File.OpenRead(filePath);

            var crc = new Crc32Accumulator();

            crc.BeginAccumulation();

            long bytesProcessed = 0;

            ChunkStream(fs, (byte[] b, int p, int len) => {
                crc.Accumulate(b, p, len);

                //
                // dispatch the block progress event if we have one
                //
                if (this.CrcProgress != null)
                {
                    bytesProcessed += len;
                    this.CrcProgress(bytesProcessed, fs.Length);
                }
            });

            crc.EndAccumulation();

            fs.Close();

            return(crc.Value);
        }
        private long CalculateFileCrc(string filePath) {
            FileStream fs = File.OpenRead(filePath);

            var crc = new Crc32Accumulator();

            crc.BeginAccumulation();

            long bytesProcessed = 0;
            ChunkStream(fs, (byte[] b, int p, int len) => {
                crc.Accumulate(b, p, len);

                //
                // dispatch the block progress event if we have one
                //
                if (this.CrcProgress != null) {
                    bytesProcessed += len;
                    this.CrcProgress(bytesProcessed, fs.Length);
                }
            });

            crc.EndAccumulation();

            fs.Close();

            return crc.Value;
        }