function ZipFiles($sourcePath,$zipFilename) { # Reference the SharpZipLib assembly here [System.Reflection.Assembly]::LoadFrom("C:\ICSharpCode.SharpZipLib.dll") $zip = New-Object ICSharpCode.SharpZipLib.Zip.FastZip $zip.CreateZip($zipFilename,$sourcePath, $true,"") } function UnzipFiles($zipFilename,$destinationPath) { # Reference the SharpZipLib assembly here [System.Reflection.Assembly]::LoadFrom("C:\ICSharpCode.SharpZipLib.dll") $zip = New-Object ICSharpCode.SharpZipLib.Zip.FastZip $zip.ExtractZip($zipFilename,$destinationPath,"") }
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult."
Thursday, 4 March 2010
How to Zip and UnZip Using Powershell
Here are some easy-to-use functions for zipping up a directory and unzipping using Powershell. The functions use the opensource SharpZipLib library, a Zip, GZip, Tar and BZip2 library written entirely in C# for the .NET platform. So you'll need to download this and reference the SharpZipLib assembly in the appropriate place in the functions below.
Subscribe to:
Post Comments (Atom)
cool thanks
ReplyDeleteThe solution is perfect. Thanks.
ReplyDelete