ICSharpCode.SharpZipLib.Checksum.BZip2Crc.Update C# (CSharp) Méthode

Update() public méthode

Updates the CRC data checksum with the bytes taken from a block of data.
public Update ( byte buffer ) : void
buffer byte Contains the data to update the CRC with.
Résultat void
        public void Update(byte[] buffer)
        {
            if (buffer == null) {
                throw new ArgumentNullException(nameof(buffer));
            }

            Update(buffer, 0, buffer.Length);
        }

Same methods

BZip2Crc::Update ( byte buffer, int offset, int count ) : void
BZip2Crc::Update ( int bval ) : void

Usage Example

    public static int Main(string[] args)
    {
        if (args.Length == 0) {
            ShowHelp();
            return 1;
        }

        var parser = new ArgumentParser(args);

        if (!File.Exists(file_)) {
            Console.Error.WriteLine("Cannot find file {0}", file_);
            ShowHelp();
            return 1;
        }

        using (FileStream checksumStream = File.OpenRead(file_)) {

            byte[] buffer = new byte[4096];
            int bytesRead;

            switch (parser.Command) {
                case Command.Help:
                    ShowHelp();
                    break;

                case Command.Crc32:
                    var currentCrc = new Crc32();
                    while ((bytesRead = checksumStream.Read(buffer, 0, buffer.Length)) > 0) {
                        currentCrc.Update(buffer, 0, bytesRead);
                    }
                    Console.WriteLine("CRC32 for {0} is 0x{1:X8}", args[0], currentCrc.Value);
                    break;

                case Command.BZip2:
                    var currentBZip2Crc = new BZip2Crc();
                    while ((bytesRead = checksumStream.Read(buffer, 0, buffer.Length)) > 0) {
                        currentBZip2Crc.Update(buffer, 0, bytesRead);
                    }
                    Console.WriteLine("BZip2CRC32 for {0} is 0x{1:X8}", args[0], currentBZip2Crc.Value);
                    break;

                case Command.Adler:
                    var currentAdler = new Adler32();
                    while ((bytesRead = checksumStream.Read(buffer, 0, buffer.Length)) > 0) {
                        currentAdler.Update(buffer, 0, bytesRead);
                    }
                    Console.WriteLine("Adler32 for {0} is 0x{1:X8}", args[0], currentAdler.Value);
                    break;
            }
        }
        return 0;
    }
All Usage Examples Of ICSharpCode.SharpZipLib.Checksum.BZip2Crc::Update