Beispiel #1
0
        public void Write(object destinationFile)
        {
            try
            {
                using (FileStream fileCompressed = new FileStream(destinationFile + Constants.GzipExtention, FileMode.OpenOrCreate))
                {
                    while (!_fileProcessData.Cancelled)
                    {
                        ByteBlock block = _queueWriter.Dequeue();

                        if (_fileProcessData.LastBlockId == block?.Id)
                        {
                            _queueWriter.Stop();
                            _gZipProgress.ProcessFinish();
                        }

                        if (block == null)
                        {
                            return;
                        }

                        BitConverter.GetBytes(block.Buffer.Length).CopyTo(block.Buffer, 4);
                        fileCompressed.Write(block.Buffer, 0, block.Buffer.Length);
                    }
                }
            }
            catch (Exception ex)
            {
                _fileProcessData.Cancelled = true;
                throw new Exception(ex.Message);
            }
        }
Beispiel #2
0
        public void Write(object destinationFile)
        {
            try
            {
                string destinationFileString = destinationFile.ToString();
                using (FileStream decompressedFile = new FileStream(destinationFileString, FileMode.OpenOrCreate))
                {
                    while (!_fileProcessData.Cancelled)
                    {
                        ByteBlock block = _queueWriter.Dequeue();

                        if (_fileProcessData.LastBlockId > 0 && _fileProcessData.LastBlockId == block?.Id)
                        {
                            _queueWriter.Stop();
                            _gZipProgress.ProcessFinish();
                        }

                        if (block == null)
                        {
                            return;
                        }

                        decompressedFile.Write(block.Buffer, 0, block.Buffer.Length);
                    }
                }
            }
            catch (Exception ex)
            {
                _fileProcessData.Cancelled = true;
                throw new Exception(ex.Message);
            }
        }