• 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 SharpSevenZipCompressor

    Class to pack data into archives supported by 7-Zip.

    Inheritance
    object
    MarshalByRefObject
    SharpSevenZipBase
    SharpSevenZipCompressor
    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 SharpSevenZipCompressor : SharpSevenZipBase
    Examples

    var compr = new SharpSevenZipCompressor(); compr.CompressDirectory(@"C:\Dir", @"C:\Archive.7z");

    Constructors

    | Edit this page View Source

    SharpSevenZipCompressor()

    Initializes a new instance of the SharpSevenZipCompressor class.

    Declaration
    public SharpSevenZipCompressor()
    | Edit this page View Source

    SharpSevenZipCompressor(string)

    Initializes a new instance of the SharpSevenZipCompressor class.

    Declaration
    public SharpSevenZipCompressor(string temporaryPath)
    Parameters
    Type Name Description
    string temporaryPath

    Your own temporary path (default is set in the parameterless constructor overload.)

    Properties

    | Edit this page View Source

    ArchiveFormat

    Gets or sets the archive format

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

    CompressionLevel

    Gets or sets the archiving compression level.

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

    CompressionMethod

    Gets or sets the compression method

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

    CompressionMode

    Gets or sets the compression mode.

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

    CustomParameters

    Gets the custom compression parameters - for advanced users only.

    Declaration
    public Dictionary<string, string> CustomParameters { get; }
    Property Value
    Type Description
    Dictionary<string, string>
    | Edit this page View Source

    DefaultItemName

    Gets or sets the default archive item name used when an item to be compressed has no name, for example, when you compress a MemoryStream instance.

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

    DirectoryStructure

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

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

    EncryptHeaders

    Gets or sets the value indicating whether to encrypt 7-Zip archive headers.

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

    FastCompression

    Gets or sets the value indicating whether to compress as fast as possible, without calling events.

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

    IncludeEmptyDirectories

    Gets or sets the value indicating whether to include empty directories to archives. Default is true.

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

    LzmaDictionarySize

    Gets or sets the dictionary size for the managed LZMA algorithm.

    Declaration
    public static int LzmaDictionarySize { get; set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    LzmaEndMarker

    Specifies mode with end marker for the managed LZMA algorithm.

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

    LzmaLitContextBits

    Specifies number of literal context bits the managed LZMA algorithm. (0 <= x <= 8).

    Declaration
    public static int LzmaLitContextBits { get; set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    LzmaLitPosBits

    Specifies number of literal position bits for the managed LZMA algorithm. (0 <= x <= 4).

    Declaration
    public static int LzmaLitPosBits { get; set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    LzmaMatchFinder

    Specifies match finder for the managed LZMA algorithm. ("BT2", "BT4" or "BT4B")

    Declaration
    public static string LzmaMatchFinder { get; set; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    LzmaNumFastBytes

    Specifies number of fast bytes for the managed LZMA algorithm.

    Declaration
    public static int LzmaNumFastBytes { get; set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    LzmaPosStateBits

    Specifies number of postion state bits the managed LZMA algorithm. (0 <= x <= 4).

    Declaration
    public static int LzmaPosStateBits { get; set; }
    Property Value
    Type Description
    int
    | Edit this page View Source

    PreserveDirectoryRoot

    Gets or sets the value indicating whether to preserve the directory root for CompressDirectory.

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

    ScanOnlyWritable

    Gets or sets the value indicating whether to compress files only open for writing.

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

    TempFolderPath

    Gets or sets the temporary folder path.

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

    VolumeSize

    Gets or sets the size in bytes of an archive volume (0 for no volumes).

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

    ZipEncryptionMethod

    Gets or sets the encryption method for zip archives.

    Declaration
    public ZipEncryptionMethod ZipEncryptionMethod { get; set; }
    Property Value
    Type Description
    ZipEncryptionMethod

    Methods

    | Edit this page View Source

    BeginCompressDirectory(string, Stream, string, string, bool)

    Packs all files in the specified directory asynchronously.

    Declaration
    public void BeginCompressDirectory(string directory, Stream archiveStream, string password, string searchPattern = "*", bool recursion = true)
    Parameters
    Type Name Description
    string directory

    The directory to compress.

    Stream archiveStream

    The archive output stream. Use CompressDirectory( ... string archiveName ... ) overloads for archiving to disk.

    string password

    The archive password.

    string searchPattern

    Search string, such as "*.txt".

    bool recursion

    If true, files will be searched for recursively; otherwise, not.

    | Edit this page View Source

    BeginCompressDirectory(string, string, string, string, bool)

    Packs all files in the specified directory asynchronously.

    Declaration
    public void BeginCompressDirectory(string directory, string archiveName, string password = "", string searchPattern = "*", bool recursion = true)
    Parameters
    Type Name Description
    string directory

    The directory to compress.

    string archiveName

    The archive file name.

    string password

    The archive password.

    string searchPattern

    Search string, such as "*.txt".

    bool recursion

    If true, files will be searched for recursively; otherwise, not.

    | Edit this page View Source

    BeginCompressFiles(Stream, int, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public void BeginCompressFiles(Stream archiveStream, int commonRootLength, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles(string archiveName, ... ) overloads for archiving to disk.

    int commonRootLength

    The length of the common root of the file names.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    BeginCompressFiles(Stream, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public void BeginCompressFiles(Stream archiveStream, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles(string archiveName ... ) overloads for archiving to disk.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    BeginCompressFiles(string, int, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public void BeginCompressFiles(string archiveName, int commonRootLength, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    int commonRootLength

    The length of the common root of the file names.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    BeginCompressFiles(string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public void BeginCompressFiles(string archiveName, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    BeginCompressFilesEncrypted(Stream, int, string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public void BeginCompressFilesEncrypted(Stream archiveStream, int commonRootLength, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles( ... string archiveName ... ) overloads for archiving to disk.

    int commonRootLength

    The length of the common root of the file names.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    BeginCompressFilesEncrypted(Stream, string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public void BeginCompressFilesEncrypted(Stream archiveStream, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles( ... string archiveName ... ) overloads for archiving to disk.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    BeginCompressFilesEncrypted(string, int, string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public void BeginCompressFilesEncrypted(string archiveName, int commonRootLength, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name

    int commonRootLength

    The length of the common root of the file names.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    BeginCompressFilesEncrypted(string, string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public void BeginCompressFilesEncrypted(string archiveName, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    BeginCompressStream(Stream, Stream, string)

    Compresses the specified stream.

    Declaration
    public void BeginCompressStream(Stream inStream, Stream outStream, string password = "")
    Parameters
    Type Name Description
    Stream inStream

    The source uncompressed stream.

    Stream outStream

    The destination compressed stream.

    string password

    The archive password.

    Exceptions
    Type Condition
    ArgumentException

    ArgumentException: at least one of the specified streams is invalid.

    | Edit this page View Source

    BeginModifyArchive(string, IDictionary<int, string?>?, string)

    Modifies the existing archive asynchronously (renames files or deletes them).

    Declaration
    public void BeginModifyArchive(string archiveName, IDictionary<int, string?>? newFileNames, string password = "")
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    IDictionary<int, string> newFileNames

    New file names. Null value to delete the corresponding index.

    string password

    The archive password.

    | Edit this page View Source

    CompressBytes(byte[])

    Compresses byte array with LZMA algorithm (C# inside)

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

    Byte array to compress

    Returns
    Type Description
    byte[]

    Compressed byte array

    | Edit this page View Source

    CompressDirectory(string, Stream, string, string, bool)

    Packs all files in the specified directory.

    Declaration
    public void CompressDirectory(string directory, Stream archiveStream, string password = "", string searchPattern = "*", bool recursion = true)
    Parameters
    Type Name Description
    string directory

    The directory to compress.

    Stream archiveStream

    The archive output stream. Use CompressDirectory( ... string archiveName ... ) overloads for archiving to disk.

    string password

    The archive password.

    string searchPattern

    Search string, such as "*.txt".

    bool recursion

    If true, files will be searched for recursively; otherwise, not.

    | Edit this page View Source

    CompressDirectory(string, string, string, string, bool)

    Packs all files in the specified directory.

    Declaration
    public void CompressDirectory(string directory, string archiveName, string password = "", string searchPattern = "*", bool recursion = true)
    Parameters
    Type Name Description
    string directory

    The directory to compress.

    string archiveName

    The archive file name.

    string password

    The archive password.

    string searchPattern

    Search string, such as "*.txt".

    bool recursion

    If true, files will be searched for recursively; otherwise, not.

    | Edit this page View Source

    CompressDirectoryAsync(string, Stream, string, string, bool)

    Packs all files in the specified directory asynchronously.

    Declaration
    public Task CompressDirectoryAsync(string directory, Stream archiveStream, string password, string searchPattern = "*", bool recursion = true)
    Parameters
    Type Name Description
    string directory

    The directory to compress.

    Stream archiveStream

    The archive output stream. Use CompressDirectory( ... string archiveName ... ) overloads for archiving to disk.

    string password

    The archive password.

    string searchPattern

    Search string, such as "*.txt".

    bool recursion

    If true, files will be searched for recursively; otherwise, not.

    Returns
    Type Description
    Task
    | Edit this page View Source

    CompressDirectoryAsync(string, string, string, string, bool)

    Packs all files in the specified directory asynchronously.

    Declaration
    public Task CompressDirectoryAsync(string directory, string archiveName, string password = "", string searchPattern = "*", bool recursion = true)
    Parameters
    Type Name Description
    string directory

    The directory to compress.

    string archiveName

    The archive file name.

    string password

    The archive password.

    string searchPattern

    Search string, such as "*.txt".

    bool recursion

    If true, files will be searched for recursively; otherwise, not.

    Returns
    Type Description
    Task
    | Edit this page View Source

    CompressFileDictionary(IDictionary<string, string>, Stream, string)

    Packs the specified file dictionary.

    Declaration
    public void CompressFileDictionary(IDictionary<string, string> fileDictionary, Stream archiveStream, string password = "")
    Parameters
    Type Name Description
    IDictionary<string, string> fileDictionary

    Dictionary<name of the archive entry, file name>. If a file name is null, the corresponding archive entry becomes a directory.

    Stream archiveStream

    The archive output stream. Use CompressStreamDictionary( ... string archiveName ... ) overloads for archiving to disk.

    string password

    The archive password.

    | Edit this page View Source

    CompressFileDictionary(IDictionary<string, string>, string, string)

    Packs the specified file dictionary.

    Declaration
    public void CompressFileDictionary(IDictionary<string, string> fileDictionary, string archiveName, string password = "")
    Parameters
    Type Name Description
    IDictionary<string, string> fileDictionary

    Dictionary<name of the archive entry, file name>. If a file name is null, the corresponding archive entry becomes a directory.

    string archiveName

    The archive file name.

    string password

    The archive password.

    | Edit this page View Source

    CompressFiles(Stream, int, params string[])

    Packs files into the archive.

    Declaration
    public void CompressFiles(Stream archiveStream, int commonRootLength, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles(string archiveName, ... ) overloads for archiving to disk.

    int commonRootLength

    The length of the common root of the file names.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    CompressFiles(Stream, params string[])

    Packs files into the archive.

    Declaration
    public void CompressFiles(Stream archiveStream, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles(string archiveName ... ) overloads for archiving to disk.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    CompressFiles(string, int, params string[])

    Packs files into the archive.

    Declaration
    public void CompressFiles(string archiveName, int commonRootLength, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    int commonRootLength

    The length of the common root of the file names.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    CompressFiles(string, params string[])

    Packs files into the archive.

    Declaration
    public void CompressFiles(string archiveName, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    CompressFilesAsync(Stream, int, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public Task CompressFilesAsync(Stream archiveStream, int commonRootLength, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles(string archiveName, ... ) overloads for archiving to disk.

    int commonRootLength

    The length of the common root of the file names.

    string[] fileFullNames

    Array of file names to pack.

    Returns
    Type Description
    Task
    | Edit this page View Source

    CompressFilesAsync(Stream, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public Task CompressFilesAsync(Stream archiveStream, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles(string archiveName ... ) overloads for archiving to disk.

    string[] fileFullNames

    Array of file names to pack.

    Returns
    Type Description
    Task
    | Edit this page View Source

    CompressFilesAsync(string, int, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public Task CompressFilesAsync(string archiveName, int commonRootLength, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    int commonRootLength

    The length of the common root of the file names.

    string[] fileFullNames

    Array of file names to pack.

    Returns
    Type Description
    Task
    | Edit this page View Source

    CompressFilesAsync(string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public Task CompressFilesAsync(string archiveName, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    string[] fileFullNames

    Array of file names to pack.

    Returns
    Type Description
    Task
    | Edit this page View Source

    CompressFilesEncrypted(Stream, int, string, params string[])

    Packs files into the archive.

    Declaration
    public void CompressFilesEncrypted(Stream archiveStream, int commonRootLength, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles( ... string archiveName ... ) overloads for archiving to disk.

    int commonRootLength

    The length of the common root of the file names.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    CompressFilesEncrypted(Stream, string, params string[])

    Packs files into the archive.

    Declaration
    public void CompressFilesEncrypted(Stream archiveStream, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles( ... string archiveName ... ) overloads for archiving to disk.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    CompressFilesEncrypted(string, int, string, params string[])

    Packs files into the archive.

    Declaration
    public void CompressFilesEncrypted(string archiveName, int commonRootLength, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    int commonRootLength

    The length of the common root of the file names.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    CompressFilesEncrypted(string, string, params string[])

    Packs files into the archive.

    Declaration
    public void CompressFilesEncrypted(string archiveName, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    | Edit this page View Source

    CompressFilesEncryptedAsync(Stream, int, string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public Task CompressFilesEncryptedAsync(Stream archiveStream, int commonRootLength, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles( ... string archiveName ... ) overloads for archiving to disk.

    int commonRootLength

    The length of the common root of the file names.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    Returns
    Type Description
    Task
    | Edit this page View Source

    CompressFilesEncryptedAsync(Stream, string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public Task CompressFilesEncryptedAsync(Stream archiveStream, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    Stream archiveStream

    The archive output stream. Use CompressFiles( ... string archiveName ... ) overloads for archiving to disk.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    Returns
    Type Description
    Task
    | Edit this page View Source

    CompressFilesEncryptedAsync(string, int, string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public Task CompressFilesEncryptedAsync(string archiveName, int commonRootLength, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name

    int commonRootLength

    The length of the common root of the file names.

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    Returns
    Type Description
    Task
    | Edit this page View Source

    CompressFilesEncryptedAsync(string, string, params string[])

    Packs files into the archive asynchronously.

    Declaration
    public Task CompressFilesEncryptedAsync(string archiveName, string password, params string[] fileFullNames)
    Parameters
    Type Name Description
    string archiveName

    The archive file name

    string password

    The archive password.

    string[] fileFullNames

    Array of file names to pack.

    Returns
    Type Description
    Task
    | Edit this page View Source

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

    Compresses the specified stream with LZMA algorithm (C# inside)

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

    The source uncompressed stream

    Stream outStream

    The destination compressed stream

    int? inLength

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

    EventHandler<ProgressEventArgs> codeProgressEvent

    The event for handling the code progress

    | Edit this page View Source

    CompressStream(Stream, Stream, string)

    Compresses the specified stream.

    Declaration
    public void CompressStream(Stream inStream, Stream outStream, string password = "")
    Parameters
    Type Name Description
    Stream inStream

    The source uncompressed stream.

    Stream outStream

    The destination compressed stream.

    string password

    The archive password.

    Exceptions
    Type Condition
    ArgumentException

    ArgumentException: at least one of the specified streams is invalid.

    | Edit this page View Source

    CompressStreamAsync(Stream, Stream, string)

    Compresses the specified stream.

    Declaration
    public Task CompressStreamAsync(Stream inStream, Stream outStream, string password = "")
    Parameters
    Type Name Description
    Stream inStream

    The source uncompressed stream.

    Stream outStream

    The destination compressed stream.

    string password

    The archive password.

    Returns
    Type Description
    Task
    Exceptions
    Type Condition
    ArgumentException

    ArgumentException: at least one of the specified streams is invalid.

    | Edit this page View Source

    CompressStreamDictionary(IDictionary<string, StreamWithAttributes>, Stream, string)

    Packs the specified stream dictionary.

    Declaration
    public void CompressStreamDictionary(IDictionary<string, StreamWithAttributes> streamDictionary, Stream archiveStream, string password = "")
    Parameters
    Type Name Description
    IDictionary<string, StreamWithAttributes> streamDictionary

    Dictionary<name of the archive entry, stream>. If a stream is null, the corresponding string becomes a directory name.

    Stream archiveStream

    The archive output stream. Use CompressStreamDictionary( ... string archiveName ... ) overloads for archiving to disk.

    string password

    The archive password.

    | Edit this page View Source

    CompressStreamDictionary(IDictionary<string, StreamWithAttributes>, string, string)

    Packs the specified stream dictionary.

    Declaration
    public void CompressStreamDictionary(IDictionary<string, StreamWithAttributes> streamDictionary, string archiveName, string password = "")
    Parameters
    Type Name Description
    IDictionary<string, StreamWithAttributes> streamDictionary

    Dictionary<name of the archive entry, stream>. If a stream is null, the corresponding string becomes a directory name.

    string archiveName

    The archive file name.

    string password

    The archive password.

    | Edit this page View Source

    ModifyArchive(string, IDictionary<int, string?>?, string)

    Modifies the existing archive (renames files or deletes them).

    Declaration
    public void ModifyArchive(string archiveName, IDictionary<int, string?>? newFileNames, string password = "")
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    IDictionary<int, string> newFileNames

    New file names. Null value to delete the corresponding index.

    string password

    The archive password.

    | Edit this page View Source

    ModifyArchiveAsync(string, IDictionary<int, string?>?, string)

    Modifies the existing archive asynchronously (renames files or deletes them).

    Declaration
    public Task ModifyArchiveAsync(string archiveName, IDictionary<int, string?>? newFileNames, string password = "")
    Parameters
    Type Name Description
    string archiveName

    The archive file name.

    IDictionary<int, string> newFileNames

    New file names. Null value to delete the corresponding index.

    string password

    The archive password.

    Returns
    Type Description
    Task

    Events

    | Edit this page View Source

    Compressing

    Occurs when data are being compressed

    Declaration
    public event EventHandler<ProgressEventArgs>? Compressing
    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

    CompressionFinished

    Occurs when the compression procedure is finished

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

    FileCompressionFinished

    Occurs when the current file was compressed.

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

    FileCompressionStarted

    Occurs when the next file is going to be packed.

    Declaration
    public event EventHandler<FileNameEventArgs>? FileCompressionStarted
    Event Type
    Type Description
    EventHandler<FileNameEventArgs>
    Remarks

    Occurs when 7-zip engine requests for an input stream for the next file to pack it

    | Edit this page View Source

    FilesFound

    Occurs when all files information was determined and SharpSevenZipCompressor is about to start to compress them.

    Declaration
    public event EventHandler<IntEventArgs>? FilesFound
    Event Type
    Type Description
    EventHandler<IntEventArgs>
    Remarks

    The incoming int value indicates the number of scanned files.

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