• Api Documentation
  • Source Code
Search Results for

    Show / Hide Table of Contents
    • SharpSevenZip
      • ArchiveFileInfo
      • ArchiveProperty
      • CompressionLevel
      • CompressionMethod
      • CompressionMode
      • EventSynchronizationStrategy
      • ExtractFileCallback
      • ICancellable
      • InArchiveFormat
      • LibraryFeature
      • OperationResult
      • OutArchiveFormat
      • SfxModule
      • SharpSevenZipArchiveFormat
      • SharpSevenZipBase
      • SharpSevenZipCompressor
      • SharpSevenZipExtractor
      • SharpSevenZipSfx
      • StreamWithAttributes
      • ZipEncryptionMethod
    • SharpSevenZip.EventArguments
      • ExtractFileCallbackArgs
      • ExtractFileCallbackReason
      • FileInfoEventArgs
      • FileNameEventArgs
      • FileOverwriteEventArgs
      • IntEventArgs
      • OpenEventArgs
      • PercentDoneEventArgs
      • ProgressEventArgs
    • SharpSevenZip.Exceptions
      • CompressionFailedException
      • ExtractionFailedException
      • LzmaException
      • SharpSevenZipArchiveException
      • SharpSevenZipCompressionFailedException
      • SharpSevenZipException
      • SharpSevenZipExtractionFailedException
      • SharpSevenZipInvalidFileNamesException
      • SharpSevenZipLibraryException
      • SharpSevenZipSfxValidationException
    • SharpSevenZip.Lzma
      • LzmaDecodeStream
      • LzmaEncodeStream
    • SharpSevenZip.Sdk
      • CoderPropId
      • ICodeProgress
      • ICoder
    • SharpSevenZip.Sdk.Compression.Lzma
      • Decoder
      • Encoder

    Class SharpSevenZipExtractor

    Class to unpack data from archives supported by 7-Zip.

    Inheritance
    object
    MarshalByRefObject
    SharpSevenZipBase
    SharpSevenZipExtractor
    Implements
    IDisposable
    Inherited Members
    SharpSevenZipBase.EventSynchronization
    SharpSevenZipBase.UniqueID
    SharpSevenZipBase.Password
    SharpSevenZipBase.SetLibraryPath(string)
    SharpSevenZipBase.CurrentLibraryFeatures
    SharpSevenZipBase.Equals(object)
    SharpSevenZipBase.GetHashCode()
    SharpSevenZipBase.ToString()
    MarshalByRefObject.GetLifetimeService()
    MarshalByRefObject.InitializeLifetimeService()
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: SharpSevenZip
    Assembly: SharpSevenZip.dll
    Syntax
    public sealed class SharpSevenZipExtractor : SharpSevenZipBase, IDisposable
    Examples

    using (var extr = new SharpSevenZipExtractor(@"C:\Test.7z")) { extr.ExtractArchive(@"C:\TestDirectory"); }

    Constructors

    | Edit this page View Source

    SharpSevenZipExtractor(Stream)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(Stream archiveStream)
    Parameters
    Type Name Description
    Stream archiveStream

    The stream to read the archive from. Use SharpSevenZipExtractor(string) to extract from disk, though it is not necessary.

    Remarks

    The archive format is guessed by the signature.

    | Edit this page View Source

    SharpSevenZipExtractor(Stream, bool)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(Stream archiveStream, bool leaveOpen)
    Parameters
    Type Name Description
    Stream archiveStream

    The stream to read the archive from. Use SharpSevenZipExtractor(string) to extract from disk, though it is not necessary.

    bool leaveOpen

    Leaves the base stream open.

    Remarks

    The archive format is guessed by the signature.

    | Edit this page View Source

    SharpSevenZipExtractor(Stream, bool, InArchiveFormat)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(Stream archiveStream, bool leaveOpen, InArchiveFormat format)
    Parameters
    Type Name Description
    Stream archiveStream

    The stream to read the archive from. Use SharpSevenZipExtractor(string) to extract from disk, though it is not necessary.

    bool leaveOpen

    Leaves the base stream open.

    InArchiveFormat format

    Manual archive format setup. You SHOULD NOT normally specify it this way. Instead, use SharpSevenZipExtractor(Stream archiveStream), that constructor automatically detects the archive format.

    | Edit this page View Source

    SharpSevenZipExtractor(Stream, string)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(Stream archiveStream, string password)
    Parameters
    Type Name Description
    Stream archiveStream

    The stream to read the archive from.

    string password

    Password for an encrypted archive.

    Remarks

    The archive format is guessed by the signature.

    | Edit this page View Source

    SharpSevenZipExtractor(Stream, string, bool)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(Stream archiveStream, string password, bool leaveOpen)
    Parameters
    Type Name Description
    Stream archiveStream

    The stream to read the archive from.

    string password

    Password for an encrypted archive.

    bool leaveOpen

    Leaves the base stream open.

    Remarks

    The archive format is guessed by the signature.

    | Edit this page View Source

    SharpSevenZipExtractor(Stream, string, bool, InArchiveFormat)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(Stream archiveStream, string password, bool leaveOpen, InArchiveFormat format)
    Parameters
    Type Name Description
    Stream archiveStream

    The stream to read the archive from.

    string password

    Password for an encrypted archive.

    bool leaveOpen

    Leaves the base stream open.

    InArchiveFormat format

    Manual archive format setup. You SHOULD NOT normally specify it this way. Instead, use SharpSevenZipExtractor(Stream archiveStream, string password), that constructor automatically detects the archive format.

    | Edit this page View Source

    SharpSevenZipExtractor(string)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(string archiveFullName)
    Parameters
    Type Name Description
    string archiveFullName

    The archive full file name.

    | Edit this page View Source

    SharpSevenZipExtractor(string, InArchiveFormat)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(string archiveFullName, InArchiveFormat format)
    Parameters
    Type Name Description
    string archiveFullName

    The archive full file name.

    InArchiveFormat format

    Manual archive format setup. You SHOULD NOT normally specify it this way. Instead, use SharpSevenZipExtractor(string archiveFullName), that constructor automatically detects the archive format.

    | Edit this page View Source

    SharpSevenZipExtractor(string, string)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(string archiveFullName, string password)
    Parameters
    Type Name Description
    string archiveFullName

    The archive full file name.

    string password

    Password for an encrypted archive.

    | Edit this page View Source

    SharpSevenZipExtractor(string, string, InArchiveFormat)

    Initializes a new instance of SharpSevenZipExtractor class.

    Declaration
    public SharpSevenZipExtractor(string archiveFullName, string password, InArchiveFormat format)
    Parameters
    Type Name Description
    string archiveFullName

    The archive full file name.

    string password

    Password for an encrypted archive.

    InArchiveFormat format

    Manual archive format setup. You SHOULD NOT normally specify it this way. Instead, use SharpSevenZipExtractor(string archiveFullName, string password), that constructor automatically detects the archive format.

    Properties

    | Edit this page View Source

    ArchiveFileData

    Gets the collection of ArchiveFileInfo with all information about files in the archive

    Declaration
    public ReadOnlyCollection<ArchiveFileInfo> ArchiveFileData { get; }
    Property Value
    Type Description
    ReadOnlyCollection<ArchiveFileInfo>
    | Edit this page View Source

    ArchiveFileNames

    Gets the collection of all file names contained in the archive.

    Declaration
    public ReadOnlyCollection<string> ArchiveFileNames { get; }
    Property Value
    Type Description
    ReadOnlyCollection<string>
    Remarks

    Each get recreates the collection

    | Edit this page View Source

    ArchiveProperties

    Gets the properties for the current archive

    Declaration
    public ReadOnlyCollection<ArchiveProperty> ArchiveProperties { get; }
    Property Value
    Type Description
    ReadOnlyCollection<ArchiveProperty>
    | Edit this page View Source

    FileName

    Gets or sets archive full file name

    Declaration
    public string? FileName { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    FilesCount

    Gets the number of files in the archive

    Declaration
    [CLSCompliant(false)]
    public uint FilesCount { get; }
    Property Value
    Type Description
    uint
    | Edit this page View Source

    Format

    Gets archive format

    Declaration
    public InArchiveFormat Format { get; }
    Property Value
    Type Description
    InArchiveFormat
    | Edit this page View Source

    IsSolid

    Gets a value indicating whether the archive is solid

    Declaration
    public bool IsSolid { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    PackedSize

    Gets the size of the archive file

    Declaration
    public long PackedSize { get; }
    Property Value
    Type Description
    long
    | Edit this page View Source

    PreserveDirectoryStructure

    Gets or sets the value indicating whether to preserve the directory structure of extracted files.

    Declaration
    public bool PreserveDirectoryStructure { get; set; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    UnpackedSize

    Gets the size of unpacked archive data

    Declaration
    public long UnpackedSize { get; }
    Property Value
    Type Description
    long
    | Edit this page View Source

    VolumeFileNames

    Gets the list of archive volume file names.

    Declaration
    public ReadOnlyCollection<string> VolumeFileNames { get; }
    Property Value
    Type Description
    ReadOnlyCollection<string>

    Methods

    | Edit this page View Source

    BeginExtractArchive(string)

    Unpacks the whole archive asynchronously to the specified directory name at the specified priority.

    Declaration
    public void BeginExtractArchive(string directory)
    Parameters
    Type Name Description
    string directory

    The directory where the files are to be unpacked.

    | Edit this page View Source

    BeginExtractFile(int, Stream)

    Unpacks the file asynchronously by its index to the specified stream.

    Declaration
    public void BeginExtractFile(int index, Stream stream)
    Parameters
    Type Name Description
    int index

    Index in the archive file table.

    Stream stream

    The stream where the file is to be unpacked.

    | Edit this page View Source

    BeginExtractFile(string, Stream)

    Unpacks the file asynchronously by its name to the specified stream.

    Declaration
    public void BeginExtractFile(string fileName, Stream stream)
    Parameters
    Type Name Description
    string fileName

    The file full name in the archive file table.

    Stream stream

    The stream where the file is to be unpacked.

    | Edit this page View Source

    BeginExtractFiles(ExtractFileCallback)

    Extracts files from the archive asynchronously, 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.

    Declaration
    public void BeginExtractFiles(ExtractFileCallback extractFileCallback)
    Parameters
    Type Name Description
    ExtractFileCallback extractFileCallback

    The callback to call for each file in the archive.

    | Edit this page View Source

    BeginExtractFiles(string, params int[])

    Unpacks files asynchronously by their indices to the specified directory.

    Declaration
    public void BeginExtractFiles(string directory, params int[] indexes)
    Parameters
    Type Name Description
    string directory

    Directory where the files are to be unpacked.

    int[] indexes

    indexes of the files in the archive file table.

    | Edit this page View Source

    BeginExtractFiles(string, params string[])

    Unpacks files asynchronously by their full names to the specified directory.

    Declaration
    public void BeginExtractFiles(string directory, params string[] fileNames)
    Parameters
    Type Name Description
    string directory

    Directory where the files are to be unpacked.

    string[] fileNames

    Full file names in the archive file table.

    | Edit this page View Source

    Check()

    Performs the archive integrity test.

    Declaration
    public bool Check()
    Returns
    Type Description
    bool

    True is the archive is ok; otherwise, false.

    | Edit this page View Source

    DecompressStream(Stream, Stream, int?, EventHandler<ProgressEventArgs>)

    Decompress the specified stream (C# inside)

    Declaration
    public static void DecompressStream(Stream inStream, Stream outStream, int? inLength, EventHandler<ProgressEventArgs> codeProgressEvent)
    Parameters
    Type Name Description
    Stream inStream

    The source compressed stream

    Stream outStream

    The destination uncompressed stream

    int? inLength

    The length of compressed data (null for inStream.Length)

    EventHandler<ProgressEventArgs> codeProgressEvent

    The event for handling the code progress

    | Edit this page View Source

    Dispose()

    Releases the unmanaged resources used by SharpSevenZipExtractor.

    Declaration
    public void Dispose()
    | Edit this page View Source

    ExtractArchive(string)

    Unpacks the whole archive to the specified directory.

    Declaration
    public void ExtractArchive(string directory)
    Parameters
    Type Name Description
    string directory

    The directory where the files are to be unpacked.

    | Edit this page View Source

    ExtractArchiveAsync(string)

    Unpacks the whole archive asynchronously to the specified directory name at the specified priority.

    Declaration
    public Task ExtractArchiveAsync(string directory)
    Parameters
    Type Name Description
    string directory

    The directory where the files are to be unpacked.

    Returns
    Type Description
    Task
    | Edit this page View Source

    ExtractBytes(byte[])

    Decompress byte array compressed with LZMA algorithm (C# inside)

    Declaration
    public static byte[] ExtractBytes(byte[] data)
    Parameters
    Type Name Description
    byte[] data

    Byte array to decompress

    Returns
    Type Description
    byte[]

    Decompressed byte array

    | Edit this page View Source

    ExtractFile(int, Stream)

    Unpacks the file by its index to the specified stream.

    Declaration
    public void ExtractFile(int index, Stream stream)
    Parameters
    Type Name Description
    int index

    Index in the archive file table.

    Stream stream

    The stream where the file is to be unpacked.

    | Edit this page View Source

    ExtractFile(string, Stream)

    Unpacks the file by its name to the specified stream.

    Declaration
    public void ExtractFile(string fileName, Stream stream)
    Parameters
    Type Name Description
    string fileName

    The file full name in the archive file table.

    Stream stream

    The stream where the file is to be unpacked.

    | Edit this page View Source

    ExtractFileAsync(int, Stream)

    Unpacks the file asynchronously by its name to the specified stream.

    Declaration
    public Task ExtractFileAsync(int index, Stream stream)
    Parameters
    Type Name Description
    int index

    Index in the archive file table.

    Stream stream

    The stream where the file is to be unpacked.

    Returns
    Type Description
    Task
    | Edit this page View Source

    ExtractFileAsync(string, Stream)

    Unpacks the file asynchronously by its name to the specified stream.

    Declaration
    public Task ExtractFileAsync(string fileName, Stream stream)
    Parameters
    Type Name Description
    string fileName

    The file full name in the archive file table.

    Stream stream

    The stream where the file is to be unpacked.

    Returns
    Type Description
    Task
    | Edit this page View Source

    ExtractFiles(ExtractFileCallback)

    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.

    Declaration
    public void ExtractFiles(ExtractFileCallback extractFileCallback)
    Parameters
    Type Name Description
    ExtractFileCallback extractFileCallback

    The callback to call for each file in the archive.

    Exceptions
    Type Condition
    SharpSevenZipExtractionFailedException

    Thrown when trying to extract from solid archives.

    | Edit this page View Source

    ExtractFiles(string, params int[])

    Unpacks files by their indices to the specified directory.

    Declaration
    public void ExtractFiles(string directory, params int[] indexes)
    Parameters
    Type Name Description
    string directory

    Directory where the files are to be unpacked.

    int[] indexes

    indexes of the files in the archive file table.

    | Edit this page View Source

    ExtractFiles(string, params string[])

    Unpacks files by their full names to the specified directory.

    Declaration
    public void ExtractFiles(string directory, params string[] fileNames)
    Parameters
    Type Name Description
    string directory

    Directory where the files are to be unpacked.

    string[] fileNames

    Full file names in the archive file table.

    | Edit this page View Source

    ExtractFilesAsync(ExtractFileCallback)

    Extracts files from the archive asynchronously, 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.

    Declaration
    public Task ExtractFilesAsync(ExtractFileCallback extractFileCallback)
    Parameters
    Type Name Description
    ExtractFileCallback extractFileCallback

    The callback to call for each file in the archive.

    Returns
    Type Description
    Task
    | Edit this page View Source

    ExtractFilesAsync(string, params int[])

    Unpacks files asynchronously by their indices to the specified directory.

    Declaration
    public Task ExtractFilesAsync(string directory, params int[] indexes)
    Parameters
    Type Name Description
    string directory

    Directory where the files are to be unpacked.

    int[] indexes

    indexes of the files in the archive file table.

    Returns
    Type Description
    Task
    | Edit this page View Source

    ExtractFilesAsync(string, params string[])

    Unpacks files asynchronously by their full names to the specified directory.

    Declaration
    public Task ExtractFilesAsync(string directory, params string[] fileNames)
    Parameters
    Type Name Description
    string directory

    Directory where the files are to be unpacked.

    string[] fileNames

    Full file names in the archive file table.

    Returns
    Type Description
    Task
    | Edit this page View Source

    OpenFileStream(int)

    Unpacks the file by its index to the specified stream.

    Declaration
    public Stream OpenFileStream(int index)
    Parameters
    Type Name Description
    int index

    Index in the archive file table.

    Returns
    Type Description
    Stream

    The stream where the file is to be unpacked.

    Events

    | Edit this page View Source

    Extracting

    Occurs when data are being extracted.

    Declaration
    public event EventHandler<ProgressEventArgs>? Extracting
    Event Type
    Type Description
    EventHandler<ProgressEventArgs>
    Remarks

    Use this event for accurate progress handling and various ProgressBar.StepBy(e.PercentDelta) routines.

    | Edit this page View Source

    ExtractionFinished

    Occurs when the archive has been unpacked.

    Declaration
    public event EventHandler<EventArgs>? ExtractionFinished
    Event Type
    Type Description
    EventHandler<EventArgs>
    | Edit this page View Source

    FileExists

    Occurs during the extraction when a file already exists.

    Declaration
    public event EventHandler<FileOverwriteEventArgs>? FileExists
    Event Type
    Type Description
    EventHandler<FileOverwriteEventArgs>
    | Edit this page View Source

    FileExtractionFinished

    Occurs when a file has been successfully unpacked.

    Declaration
    public event EventHandler<FileInfoEventArgs>? FileExtractionFinished
    Event Type
    Type Description
    EventHandler<FileInfoEventArgs>
    | Edit this page View Source

    FileExtractionStarted

    Occurs when a new file is going to be unpacked.

    Declaration
    public event EventHandler<FileInfoEventArgs>? FileExtractionStarted
    Event Type
    Type Description
    EventHandler<FileInfoEventArgs>
    Remarks

    Occurs when 7-zip engine requests for an output stream for a new file to unpack in.

    Implements

    IDisposable
    • Edit this page
    • View Source
    In this article
    Back to top Copyright (C) Markovtsev Vadim 2009, 2010, Jérémy Ansel 2024