C# Class StreamUnpack, extensions

Provides unpacking behavior for steams are OPC (Open Packaging Convention) packages/zips.
显示文件 Open project: netfx/extensions

Public Methods

Method Description
Unpack ( this zipStream, string fileToUnpack, Stream unpacked ) : bool

From the given stream, unzips the file with the given name onto the given unpacked stream.

If the fileToUnpack is not found, nothing gets written to unpacked.

Unpack ( this zipStream, string targetDir ) : void

Unzips the given stream onto the target directory.

If the targetDir already exists, it's deleted before unzipping begins to ensure a clean destination folder.

The compressed stream must be a proper Package in term of XPS/OPC (at a minimum, have a [Content_Types].xml).

Private Methods

Method Description
BuildTargetFileName ( string baseDir, Uri partUri ) : string
GetFileName ( string uri ) : string
ShouldUnpack ( string filePath, string filesToUnpack ) : bool

Method Details

Unpack() public static method

From the given stream, unzips the file with the given name onto the given unpacked stream.
If the fileToUnpack is not found, nothing gets written to unpacked.
public static Unpack ( this zipStream, string fileToUnpack, Stream unpacked ) : bool
zipStream this The stream to unpack
fileToUnpack string The file inside te pack to unpack
unpacked Stream The stream where the file will be unpacked
return bool

Unpack() public static method

Unzips the given stream onto the target directory.
If the targetDir already exists, it's deleted before unzipping begins to ensure a clean destination folder.

The compressed stream must be a proper Package in term of XPS/OPC (at a minimum, have a [Content_Types].xml).

public static Unpack ( this zipStream, string targetDir ) : void
zipStream this The stream to unpack
targetDir string The target directory where stream will be unpacked
return void