Last active
December 31, 2015 22:29
-
-
Save grenade/8054334 to your computer and use it in GitHub Desktop.
Extract a single file from a zip file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| param( | |
| [string] $archive, | |
| [string] $savePath, | |
| [string] $filename = [System.IO.Path]::GetFileName($savePath) | |
| ) | |
| [Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem") | Out-Null | |
| $outStream = New-Object System.IO.FileStream ("$savePath"), 'Create' | |
| $inStream = ([System.IO.Compression.ZipFile]::OpenRead($archive).Entries | Where { $_.Name -eq $filename }).Open() | |
| $inStream.CopyTo($outStream) | |
| $inStream.Close() | |
| $outStream.Close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment