ZipArchive.AddFileAsync Method
Namespace: Rebex.IO.Compression
Assembly: Rebex.Zip.dll (version 7.0.9313)
AddFileAsync(String, String, Object)
Begins asynchronous AddFile operation. Adds the specified local file to the specified directory within the ZIP archive.
Declaration
public Task<ArchiveOperationResult> AddFileAsync(string sourceFilePath, string archivePath, object state = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | sourceFilePath | Path to a local file to be added. |
| String | archivePath | Path to a (non-existing) file archive item or path to a directory item ending with directory separator (typically ''). Null reference (Nothing in Visual Basic) means root. |
| Object | state | An optional user-provided object that identifies this particular asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<ArchiveOperationResult> | Operation result. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException | The specified path is empty or contains invalid characters. -or- The system could not retrieve the absolute path. |
| InvalidOperationException | Archive is not opened for writing.
-or- |
| ObjectDisposedException | Archive was already disposed. |
| NotSupportedException | Path is in an invalid format. |
| PathTooLongException |
|
| DirectoryNotFoundException | Part of the source path was not found. |
| FileNotFoundException | The source file was not found. |
| SecurityException | The caller does not have the required permissions. |
| UnauthorizedAccessException | Access to the file is denied. |
| IOException | An I/O error occurred. |
| ZipException | Cannot perform the requested operation, or the operation was canceled (see ProblemType for detailed information). |
AddFileAsync(String, String, ActionOnExistingFiles, Object)
Begins asynchronous AddFile operation. Adds the specified local file to the specified directory within the ZIP archive.
Declaration
public Task<ArchiveOperationResult> AddFileAsync(string sourceFilePath, string archivePath, ActionOnExistingFiles defaultActionOnExistingFiles, object state = null)
Parameters
| Type | Name | Description |
|---|---|---|
| String | sourceFilePath | Path to a local file to be added. |
| String | archivePath | Path to a (non-existing) file archive item or path to a directory item ending with directory separator (typically ''). Null reference (Nothing in Visual Basic) means root. |
| ActionOnExistingFiles | defaultActionOnExistingFiles | Specifies the default behavior for files that already exists in the local directory. |
| Object | state | An optional user-provided object that identifies this particular asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<ArchiveOperationResult> | Operation result. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException | The specified path is empty or contains invalid characters. -or- The system could not retrieve the absolute path. |
| InvalidOperationException | Archive is not opened for writing.
-or- |
| ObjectDisposedException | Archive was already disposed. |
| NotSupportedException | Path is in an invalid format. |
| PathTooLongException |
|
| DirectoryNotFoundException | Part of the source path was not found. |
| FileNotFoundException | The source file was not found. |
| SecurityException | The caller does not have the required permissions. |
| UnauthorizedAccessException | Access to the file is denied. |
| IOException | An I/O error occurred. |
| ZipException | Cannot perform the requested operation, or the operation was canceled (see ProblemType for detailed information). |
AddFileAsync(Stream, String, Object)
Begins asynchronous AddFile operation. Adds data from the specified stream to the ZIP archive.
Declaration
public Task<ArchiveOperationResult> AddFileAsync(Stream inputStream, string archiveFilePath, object state = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | inputStream | Stream to read the data from. |
| String | archiveFilePath | Absolute path to a (non-existing) file item within the ZIP archive. |
| Object | state | An optional user-provided object that identifies this particular asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<ArchiveOperationResult> | Operation result. |
Remarks
Note that only data following the current position of the input stream is compressed.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException |
|
| InvalidOperationException | Archive is not opened for writing.
-or- |
| ObjectDisposedException | Archive was already disposed. |
| PathTooLongException |
|
| IOException | An I/O error occurred. |
| ZipException | Cannot perform the requested operation, or the operation was canceled (see ProblemType for detailed information). |
AddFileAsync(Stream, String, ActionOnExistingFiles, Object)
Begins asynchronous AddFile operation. Adds data from the specified stream to the ZIP archive.
Declaration
public Task<ArchiveOperationResult> AddFileAsync(Stream inputStream, string archiveFilePath, ActionOnExistingFiles defaultActionOnExistingFiles, object state = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | inputStream | Stream to read the data from. |
| String | archiveFilePath | Absolute path to a (non-existing) file item within the ZIP archive. |
| ActionOnExistingFiles | defaultActionOnExistingFiles | Specifies the default behavior for files that already exists in the local directory. |
| Object | state | An optional user-provided object that identifies this particular asynchronous operation. |
Returns
| Type | Description |
|---|---|
| Task<ArchiveOperationResult> | Operation result. |
Remarks
Note that only data following the current position of the input stream is compressed.
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException |
|
| ArgumentException |
|
| InvalidOperationException | Archive is not opened for writing.
-or- |
| ObjectDisposedException | Archive was already disposed. |
| PathTooLongException |
|
| IOException | An I/O error occurred. |
| ZipException | Cannot perform the requested operation, or the operation was canceled (see ProblemType for detailed information). |