Adds the specified local file to the specified directory within the ZIP archive.

Namespace:  Rebex.IO.Compression
Assembly:  Rebex.Zip (in Rebex.Zip.dll)

Syntax

Visual Basic
Public Function AddFile ( _
	sourceFilePath As String, _
	archivePath As String, _
	defaultActionOnExistingFiles As ActionOnExistingFiles _
) As ArchiveOperationResult
C#
public ArchiveOperationResult AddFile(
	string sourceFilePath,
	string archivePath,
	ActionOnExistingFiles defaultActionOnExistingFiles
)

Parameters

sourceFilePath
Type: System..::..String
Path to a local file to be added.
archivePath
Type: System..::..String
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.
defaultActionOnExistingFiles
Type: Rebex.IO..::..ActionOnExistingFiles
Specifies the default behavior for files that already exists in the local directory.

Return Value

Operation result.

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionsourceFilePath is null.
System..::..ArgumentExceptionThe specified path is empty or contains invalid characters. -or- The system could not retrieve the absolute path.
System..::..InvalidOperationExceptionArchive is not opened for writing. -or- sourceFilePath refers to the ZIP archive itself.
System..::..ObjectDisposedExceptionArchive was already disposed.
System..::..NotSupportedExceptionPath is in an invalid format.
System.IO..::..PathTooLongExceptionsourceFilePath exceed the maximum length defined by system. -or- archivePath is longer than 65.535 characters.
System.IO..::..DirectoryNotFoundExceptionPart of the source path was not found.
System.IO..::..FileNotFoundExceptionThe source file was not found.
System.Security..::..SecurityExceptionThe caller does not have the required permissions.
System..::..UnauthorizedAccessExceptionAccess to the file is denied.
System.IO..::..IOExceptionAn I/O error occurred.
Rebex.IO.Compression..::..ZipExceptionCannot perform the requested operation, or the operation was canceled (see ProblemType for detailed information).

Version Information

.NET Compact Framework

Supported in: 3.9, 3.5

See Also