SevenZipArchive.SevenZipArchive
Contents
[
Hide
]SevenZipArchive(SevenZipEntrySettings)
Initializes a new instance of the SevenZipArchive
class with optional settings for its entries.
public SevenZipArchive(SevenZipEntrySettings newEntrySettings = null)
Parameter | Type | Description |
---|---|---|
newEntrySettings | SevenZipEntrySettings | Compression and encryption settings used for newly added SevenZipArchiveEntry items. If not specified, LZMA compression without encryption would be used. |
Examples
The following example shows how to compress a single file with default settings: LZMA compression without encryption.
using (FileStream sevenZipFile = File.Open("archive.7z", FileMode.Create))
{
using (var archive = new SevenZipArchive())
{
archive.CreateEntry("data.bin", "file.dat");
archive.Save(sevenZipFile);
}
}
See Also
- class SevenZipEntrySettings
- class SevenZipArchive
- namespace Aspose.Zip.SevenZip
- assembly Aspose.Zip
SevenZipArchive(Stream, string)
Initializes a new instance of the SevenZipArchive
class and composes entries list can be extracted from the archive.
public SevenZipArchive(Stream sourceStream, string password = null)
Parameter | Type | Description |
---|---|---|
sourceStream | Stream | The source of the archive. |
password | String | Optional password for decryption. If file names are encrypted it must be present. |
Exceptions
exception | condition |
---|---|
ArgumentException | sourceStream is not seekable. |
ArgumentNullException | sourceStream is null. |
NotImplementedException | Archive contains more than one coder. Now only LZMA compression supported. |
Remarks
This constructor does not decompress any entry. See ExtractToDirectory
method for decompressing.
Examples
using (SevenZipArchive archive = new SevenZipArchive(File.OpenRead("archive.7z")))
{
archive.ExtractToDirectory("C:\\extracted");
}
See Also
- class SevenZipArchive
- namespace Aspose.Zip.SevenZip
- assembly Aspose.Zip
SevenZipArchive(string, string)
Initializes a new instance of the SevenZipArchive
class and composes entries list can be extracted from the archive.
public SevenZipArchive(string path, string password = null)
Parameter | Type | Description |
---|---|---|
path | String | The fully qualified or the relative path to the archive file. |
password | String | Optional password for decryption. If file names are encrypted it must be present. |
Exceptions
exception | condition |
---|---|
ArgumentNullException | path is null. |
SecurityException | The caller does not have the required permission to access. |
ArgumentException | The path is empty, contains only white spaces, or contains invalid characters. |
UnauthorizedAccessException | Access to file path is denied. |
PathTooLongException | The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. |
NotSupportedException | File at path contains a colon (:) in the middle of the string. |
Remarks
This constructor does not decompress any entry. See ExtractToDirectory
method for decompressing.
Examples
using (SevenZipArchive archive = new SevenZipArchive("archive.7z"))
{
archive.ExtractToDirectory("C:\\extracted");
}
See Also
- class SevenZipArchive
- namespace Aspose.Zip.SevenZip
- assembly Aspose.Zip