0
创建压缩文件
下面的代码呼啸而过以下文件:包括顶级目录成PowerShell中
c:\test\1.txt
c:\test\2.txt
c:\test\3.txt
到test.zip,如:
1.txt
2.txt
3.txt
但我想是包括目录测试:
test\1.txt
test\2.txt
test\3.txt
任何想法如何做到这一点?
$zipFilename = 'c:\test.zip'
$zipDir = 'c:\test'
Set-Content $zipFilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
$shell = New-Object -ComObject Shell.Application
$zipPackage = $shell.NameSpace($zipFilename)
Get-ChildItem $zipDir -Recurse | foreach {
# echo $_.FullName
$zipPackage.CopyHere($_.FullName)
Start-Sleep -Milliseconds 1000
}
谢谢,它看起来像我错过了显而易见的! – 2014-10-07 06:28:38