SevenZip/SevenZipExtractor.cs
/// <summary>
///   Extracts files from the archive, giving a callback the choice what
///   to do with each file. The order of the files is given by the archive.
///   7-Zip (and any other solid) archives are NOT supported.
/// </summary>
/// <param name = "extractFileCallback">The callback to call for each file in the archive.</param>
Extracts files from the archive, giving a callback the choice what
to do with each file. The order of the files is given by the archive.
7-Zip (and any other solid) archives are NOT supported.
Extracts files from the archive giving a callback the choice what to do with each file . The order of the files is given by the archive . 7 - Zip ( and any other solid ) archives are NOT supported .
public void ExtractFiles(ExtractFileCallback extractFileCallback)
        {
            DisposedCheck();
            InitArchiveFileData(false);
            if (IsSolid)
            {
            }
            else
            {
                foreach (ArchiveFileInfo archiveFileInfo in ArchiveFileData)
                {
                    var extractFileCallbackArgs = new ExtractFileCallbackArgs(archiveFileInfo);
                    extractFileCallback(extractFileCallbackArgs);
                    if (extractFileCallbackArgs.CancelExtraction)
                    {
                        break;
                    }
                    if (extractFileCallbackArgs.ExtractToStream != null || extractFileCallbackArgs.ExtractToFile != null)
                    {
                        bool callDone = false;
                        try
                        {
                            if (extractFileCallbackArgs.ExtractToStream != null)
                            {
                                ExtractFile(archiveFileInfo.Index, extractFileCallbackArgs.ExtractToStream);
                            }
                            else
                            {
                                using (
                                    var file = new FileStream(extractFileCallbackArgs.ExtractToFile, FileMode.CreateNew,
                                                              FileAccess.Write, FileShare.None, 8192))
                                {
                                    ExtractFile(archiveFileInfo.Index, file);
                                }
                            }
                            callDone = true;
                        }
                        catch (Exception ex)
                        {
                            extractFileCallbackArgs.Exception = ex;
                            extractFileCallbackArgs.Reason = ExtractFileCallbackReason.Failure;
                            extractFileCallback(extractFileCallbackArgs);
                            if (!ThrowException(null, ex))
                            {
                                return;
                            }
                        }
                        if (callDone)
                        {
                            extractFileCallbackArgs.Reason = ExtractFileCallbackReason.Done;
                            extractFileCallback(extractFileCallbackArgs);
                        }
                    }
                }
            }
        }
public void ExtractFiles ( ExtractFileCallback extractFileCallback ) { DisposedCheck ( ) ; InitArchiveFileData ( false ) ; if ( IsSolid ) { } else { foreach ( ArchiveFileInfo archiveFileInfo in ArchiveFileData ) { var extractFileCallbackArgs = new ExtractFileCallbackArgs ( archiveFileInfo ) ; extractFileCallback ( extractFileCallbackArgs ) ; if ( extractFileCallbackArgs . CancelExtraction ) { break ; } if ( extractFileCallbackArgs . ExtractToStream != null || extractFileCallbackArgs . ExtractToFile != null ) { bool callDone = false ; try { if ( extractFileCallbackArgs . ExtractToStream != null ) { ExtractFile ( archiveFileInfo . Index , extractFileCallbackArgs . ExtractToStream ) ; } else { using ( var file = new FileStream ( extractFileCallbackArgs . ExtractToFile , FileMode . CreateNew , FileAccess . Write , FileShare . None , 8192 ) ) { ExtractFile ( archiveFileInfo . Index , file ) ; } } callDone = true ; } catch ( Exception ex ) { extractFileCallbackArgs . Exception = ex ; extractFileCallbackArgs . Reason = ExtractFileCallbackReason . Failure ; extractFileCallback ( extractFileCallbackArgs ) ; if ( ! ThrowException ( null , ex ) ) { return ; } } if ( callDone ) { extractFileCallbackArgs . Reason = ExtractFileCallbackReason . Done ; extractFileCallback ( extractFileCallbackArgs ) ; } } } } }
Extracts files from the archive, giving a callback the choice what
to do with each file.
Extracts files from the archive giving a callback the choice what to do with each file .
// solid strategy
extractFileCallback
ExtractFileCallback
The callback to call for each file in the archive.
The callback to call for each file in the archive .