I’m using the following function to add files to a .zip archive which works fine, but I need to be able to include the parent directory for some of the files. Any ideas?
function Add-ZipFile
{
param([string]$zipfilename,
[string]$filter)
if(-not (test-path($zipfilename)))
{
set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
(dir $zipfilename).IsReadOnly = $false
}
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($zipfilename)
$files = get-childitem -Filter "$filter" -recurse
foreach($file in $files)
{
$zipPackage.CopyHere($file.FullName)
Start-sleep -milliseconds 500
}
}
Ended up using CSharpZipLib. Worked as I’d hoped.
Thanks everyone.