Example #1
0
        public void SetOperationResult(OperationResult operationResult)
        {
            if (operationResult != OperationResult.Ok && ReportErrors)
            {
                switch (operationResult)
                {
                case OperationResult.CrcError:
                    AddException(new ExtractionFailedException("File is corrupted. Crc check has failed."));
                    break;

                case OperationResult.DataError:
                    AddException(new ExtractionFailedException("File is corrupted. Data error has occured."));
                    break;

                case OperationResult.UnsupportedMethod:
                    AddException(new ExtractionFailedException("Unsupported method error has occured."));
                    break;
                }
            }
            if (_fileStream != null)
            {
                _fileStream.BytesRead -= IntEventArgsHandler;
                //Specific Zip implementation - can not Dispose files for Zip.
                if (_compressor.ArchiveFormat != OutArchiveFormat.Zip)
                {
                    try
                    {
                        _fileStream.Dispose();
                    }
                    catch (ObjectDisposedException) {}
                }
                else
                {
                    _wrappersToDispose.Add(_fileStream);
                }
                _fileStream = null;
                GC.Collect();
                // Issue #6987
                //GC.WaitForPendingFinalizers();
            }
            OnFileCompressionFinished(EventArgs.Empty);
        }