ZipArchive.AddFile Method
Namespace: Rebex.IO.Compression
Assembly: Rebex.Zip.dll (version 7.0.9313)
AddFile(String)
Adds the specified file to the root directory of the ZIP archive.
Declaration
public ArchiveOperationResult AddFile(string sourceFilePath)
Parameters
| Type | Name | Description |
|---|---|---|
| String | sourceFilePath | Path to a local file to be added. |
Returns
| Type | Description |
|---|---|
| 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 specified path was not found. |
| FileNotFoundException | The specified file path 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). |
AddFile(String, String)
Adds the specified local file to the specified directory within the ZIP archive.
Declaration
public ArchiveOperationResult AddFile(string sourceFilePath, string archivePath)
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. |
Returns
| Type | Description |
|---|---|
| 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). |
AddFile(String, String, ActionOnExistingFiles)
Adds the specified local file to the specified directory within the ZIP archive.
Declaration
public ArchiveOperationResult AddFile(string sourceFilePath, string archivePath, ActionOnExistingFiles defaultActionOnExistingFiles)
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. |
Returns
| Type | Description |
|---|---|
| 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). |
AddFile(Stream, String)
Adds data from the specified stream to the ZIP archive.
Declaration
public ArchiveOperationResult AddFile(Stream inputStream, string archiveFilePath)
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. |
Returns
| Type | Description |
|---|---|
| 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). |
AddFile(Stream, String, ActionOnExistingFiles)
Adds data from the specified stream to the ZIP archive.
Declaration
public ArchiveOperationResult AddFile(Stream inputStream, string archiveFilePath, ActionOnExistingFiles defaultActionOnExistingFiles)
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. |
Returns
| Type | Description |
|---|---|
| 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). |