C# Class EnterpriseWebLibrary.IO.ZipOps

Contains methods that zip and unzip data.
Mostrar archivo Open project: enduracode/enterprise-web-library

Public Methods

Method Description
UnZipByteArrayAsFolder ( byte sourceData, string destinationFolderPath ) : void

Unzips the specified ZIP byte array into a new folder with the specified path. If a folder already exists at the path, it is deleted.

UnZipFileAsFolder ( string sourceFilePath, string destinationFolderPath ) : void

Unzips the specified ZIP file into a new folder with the specified path. If a folder already exists at the path, it is deleted.

UnZipStreamAsFileObjects ( Stream source ) : IEnumerable

This method completely ignores directory structure of the zip file in the source stream. The result is a flattened list of files. But, the file names do contain the relative path information, so they can be used to re-create the directory structure.

UnZipStreamAsFolder ( Stream sourceStream, string destinationFolderPath ) : void

Unzips the specified ZIP stream into a new folder with the specified path. If a folder already exists at the path, it is deleted.

UnZipStreamIntoFolder ( Stream sourceStream, string destinationFolderPath ) : void

Unzips the specified ZIP stream to the new or existing folder. If the folder already exists, archive items will be added to the existing folder structure. Files will be overwritten when there is an existing file with the same name as an archive file.

ZipFileObjectsAsStream ( IEnumerable files, Stream destination ) : void

Creates a zip file into the destination stream, given the sources. Tuple file names will be cleaned. File names must include extension.

ZipFileStreamsAsStream ( Stream>.IEnumerable fileNameAndSources, Stream destination ) : void

Creates a zip file into the destination stream, given the sources. Tuple file names will be cleaned. File names must include extension.

ZipFilesAsStream ( IEnumerable filePaths, Stream outputStream ) : void

Zips all specified files into a stream. All files are put in the root of the zip file. The caller is responsible for disposing the stream.

ZipFolderAsByteArray ( string sourceFolderPath ) : byte[]

Zips all files and folders (recursively) in the specified folder into a ZIP byte array that represents a zip file.

ZipFolderAsFile ( string sourceFolderPath, string destinationFilePath ) : void

Zips all files in the specified folder into a new ZIP file with the specified path. If a file already exists at the path, it is overwritten.

ZipFolderAsStream ( string sourceFolderPath, Stream outputStream ) : void

Zips all files and folders (recursively) in the specified folder into a memory stream. The caller is responsible for disposing the stream.

Private Methods

Method Description
Test ( ) : void
createZipOutputStream ( Stream s ) : ZipOutputStream
writeZipEntry ( ZipEntry zipEntry, Stream sourceStream, ZipOutputStream zipOutputStream ) : void

Method Details

UnZipByteArrayAsFolder() public static method

Unzips the specified ZIP byte array into a new folder with the specified path. If a folder already exists at the path, it is deleted.
public static UnZipByteArrayAsFolder ( byte sourceData, string destinationFolderPath ) : void
sourceData byte
destinationFolderPath string
return void

UnZipFileAsFolder() public static method

Unzips the specified ZIP file into a new folder with the specified path. If a folder already exists at the path, it is deleted.
public static UnZipFileAsFolder ( string sourceFilePath, string destinationFolderPath ) : void
sourceFilePath string
destinationFolderPath string
return void

UnZipStreamAsFileObjects() public static method

This method completely ignores directory structure of the zip file in the source stream. The result is a flattened list of files. But, the file names do contain the relative path information, so they can be used to re-create the directory structure.
public static UnZipStreamAsFileObjects ( Stream source ) : IEnumerable
source Stream
return IEnumerable

UnZipStreamAsFolder() public static method

Unzips the specified ZIP stream into a new folder with the specified path. If a folder already exists at the path, it is deleted.
public static UnZipStreamAsFolder ( Stream sourceStream, string destinationFolderPath ) : void
sourceStream Stream
destinationFolderPath string
return void

UnZipStreamIntoFolder() public static method

Unzips the specified ZIP stream to the new or existing folder. If the folder already exists, archive items will be added to the existing folder structure. Files will be overwritten when there is an existing file with the same name as an archive file.
public static UnZipStreamIntoFolder ( Stream sourceStream, string destinationFolderPath ) : void
sourceStream Stream
destinationFolderPath string
return void

ZipFileObjectsAsStream() public static method

Creates a zip file into the destination stream, given the sources. Tuple file names will be cleaned. File names must include extension.
public static ZipFileObjectsAsStream ( IEnumerable files, Stream destination ) : void
files IEnumerable
destination Stream
return void

ZipFileStreamsAsStream() public static method

Creates a zip file into the destination stream, given the sources. Tuple file names will be cleaned. File names must include extension.
public static ZipFileStreamsAsStream ( Stream>.IEnumerable fileNameAndSources, Stream destination ) : void
fileNameAndSources Stream>.IEnumerable
destination Stream
return void

ZipFilesAsStream() public static method

Zips all specified files into a stream. All files are put in the root of the zip file. The caller is responsible for disposing the stream.
public static ZipFilesAsStream ( IEnumerable filePaths, Stream outputStream ) : void
filePaths IEnumerable
outputStream Stream
return void

ZipFolderAsByteArray() public static method

Zips all files and folders (recursively) in the specified folder into a ZIP byte array that represents a zip file.
public static ZipFolderAsByteArray ( string sourceFolderPath ) : byte[]
sourceFolderPath string
return byte[]

ZipFolderAsFile() public static method

Zips all files in the specified folder into a new ZIP file with the specified path. If a file already exists at the path, it is overwritten.
public static ZipFolderAsFile ( string sourceFolderPath, string destinationFilePath ) : void
sourceFolderPath string
destinationFilePath string
return void

ZipFolderAsStream() public static method

Zips all files and folders (recursively) in the specified folder into a memory stream. The caller is responsible for disposing the stream.
public static ZipFolderAsStream ( string sourceFolderPath, Stream outputStream ) : void
sourceFolderPath string
outputStream Stream
return void