Rebex
Products Downloads Buy Support Contact
Show / Hide Table of Contents

ZipArchive.AddFileAsync Method

Namespace: Rebex.IO.Compression
Assembly: Rebex.Zip.dll (version 7.0.9147)

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 '&apos;). 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

sourceFilePath is null.

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- sourceFilePath refers to the ZIP archive itself.

ObjectDisposedException

Archive was already disposed.

NotSupportedException

Path is in an invalid format.

PathTooLongException

sourceFilePath exceed the maximum length defined by system. -or- archivePath is longer than 65.535 characters.

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 '&apos;). 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

sourceFilePath is null.

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- sourceFilePath refers to the ZIP archive itself.

ObjectDisposedException

Archive was already disposed.

NotSupportedException

Path is in an invalid format.

PathTooLongException

sourceFilePath exceed the maximum length defined by system. -or- archivePath is longer than 65.535 characters.

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

inputStream is null.

ArgumentException

archiveFilePath is empty or contains invalid characters.

InvalidOperationException

Archive is not opened for writing. -or- inputStream refers to the ZIP archive itself.

ObjectDisposedException

Archive was already disposed.

PathTooLongException

archiveFilePath is longer than 65.535 characters.

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

inputStream is null.

ArgumentException

archiveFilePath is empty or contains invalid characters.

InvalidOperationException

Archive is not opened for writing. -or- inputStream refers to the ZIP archive itself.

ObjectDisposedException

Archive was already disposed.

PathTooLongException

archiveFilePath is longer than 65.535 characters.

IOException

An I/O error occurred.

ZipException

Cannot perform the requested operation, or the operation was canceled (see ProblemType for detailed information).

In This Article
  • AddFileAsync(String, String, Object)
  • AddFileAsync(String, String, ActionOnExistingFiles, Object)
  • AddFileAsync(Stream, String, Object)
  • AddFileAsync(Stream, String, ActionOnExistingFiles, Object)
© REBEX ČR s.r.o. Back to top
Privacy policy
Manage cookies