GzipArchive.GzipArchive
GzipArchive()
Initializes a new instance of the GzipArchive class prepared for compressing.
public GzipArchive()
Examples
The following example shows how to compress a file.
using (GzipArchive archive = new GzipArchive())
{
archive.SetSource("data.bin");
archive.Save("archive.gz");
}
See Also
- class GzipArchive
- namespace Aspose.Zip.Gzip
- assembly Aspose.Zip
GzipArchive(Stream, bool)
Initializes a new instance of the GzipArchive class prepared for decompressing.
public GzipArchive(Stream sourceStream, bool parseHeader = false)
| Parameter | Type | Description |
|---|---|---|
| sourceStream | Stream | The source of the archive. |
| parseHeader | Boolean | Whether to parse stream header to figure out properties, including name. Makes sense for seekable stream only. |
Exceptions
| exception | condition |
|---|---|
| ArgumentNullException | sourceStream is null. |
| EndOfStreamException | sourceStream is too short. |
| InvalidDataException | The sourceStream has wrong signature. |
Remarks
This constructor does not decompress. See Open method for decompressing.
Examples
Open an archive from a stream and extract it to a MemoryStream
var ms = new MemoryStream();
using (GzipArchive archive = new GzipArchive(File.OpenRead("archive.gz")))
archive.Open().CopyTo(ms);
See Also
- class GzipArchive
- namespace Aspose.Zip.Gzip
- assembly Aspose.Zip
GzipArchive(Stream, GzipLoadOptions)
Initializes a new instance of the GzipArchive class prepared for decompressing.
public GzipArchive(Stream sourceStream, GzipLoadOptions options)
| Parameter | Type | Description |
|---|---|---|
| sourceStream | Stream | The source of the archive. |
| options | GzipLoadOptions | Options to load the archive with. |
Exceptions
| exception | condition |
|---|---|
| ArgumentNullException | sourceStream is null. |
| EndOfStreamException | sourceStream is too short. |
| InvalidDataException | The sourceStream has wrong signature. |
Remarks
This constructor does not decompress. See Open method for decompressing.
Examples
Open an archive from a stream and extract it to a MemoryStream
var ms = new MemoryStream();
GzipLoadOptions options = new GzipLoadOptions();
using (GzipArchive archive = new GzipArchive(File.OpenRead("archive.gz"), options))
archive.Extract(ms);
See Also
- class GzipLoadOptions
- class GzipArchive
- namespace Aspose.Zip.Gzip
- assembly Aspose.Zip
GzipArchive(string, GzipLoadOptions)
Initializes a new instance of the GzipArchive class prepared for decompressing.
public GzipArchive(string path, GzipLoadOptions options)
| Parameter | Type | Description |
|---|---|---|
| path | String | The path to the archive file. |
| options | GzipLoadOptions | Options to load the archive with. |
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. |
| EndOfStreamException | The file is too short. |
| InvalidDataException | Data in the file has the wrong signature. |
Remarks
This constructor does not decompress. See Open method for decompressing.
Examples
Open an archive from file by path and extract it to a MemoryStream
var ms = new MemoryStream();
GzipLoadOptions options = new GzipLoadOptions();
using (GzipArchive archive = new GzipArchive("archive.gz", options))
archive.Extract(ms);
See Also
- class GzipLoadOptions
- class GzipArchive
- namespace Aspose.Zip.Gzip
- assembly Aspose.Zip
GzipArchive(string, bool)
Initializes a new instance of the GzipArchive class prepared for decompressing.
public GzipArchive(string path, bool parseHeader = false)
| Parameter | Type | Description |
|---|---|---|
| path | String | The path to the archive file. |
| parseHeader | Boolean | Whether to parse stream header to figure out properties, including name. Makes sense for seekable stream only. |
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. |
| EndOfStreamException | The file is too short. |
| InvalidDataException | Data in the file has wrong signature. |
Remarks
This constructor does not decompress. See Open method for decompressing.
Examples
Open an archive from file by path and extract it to a MemoryStream
var ms = new MemoryStream();
using (GzipArchive archive = new GzipArchive("archive.gz"))
archive.Open().CopyTo(ms);
See Also
- class GzipArchive
- namespace Aspose.Zip.Gzip
- assembly Aspose.Zip