-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Description
Steps to reproduce
Execute a test script.
if (Test-Path 'Root')
{
Remove-Item 'Root' -Recurse -Force
}
Remove-Item *.zip
$path = 'Root\Level0\LastDir'
New-Item -ItemType Directory $path | Out-Null
New-Item -ItemType Directory "$path\EmptyDir" | Out-Null
Set-Content "$path\Document.txt" (Get-Date)
Compress-Archive 'Root' 'Test1.zip'
Add-Type -AssemblyName 'System.IO.Compression.FileSystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory("$PSScriptRoot\Root", "$PSScriptRoot\Test2.zip")
$sevenZip = 'C:\Program Files\7-Zip\7z.exe'
if (Test-Path $sevenZip)
{
&$sevenZip a 'Test3.zip' 'Root'
}Test1.zip is created by PowerShell, Test2.zip - by .NET 4.5 ZipFile, Test3.zip - by 7-Zip.
Test1.zip can't be extracted.
Test2.zip has invalid zero file instead of empty directory.
Test3.zip is correct.
Expected behavior
Created archive with correct structure.
Root/Level0/LastDir/EmptyDir/
Root/Level0/LastDir/Document.txt
Actual behavior
Every directory that does not contain files has a duplicating zero-length file in the archive.
Empty directory is converted to file.
Root/Level0/LastDir/Document.txt
Root/Level0/LastDir/EmptyDir
Root/Level0
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.693
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.693
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1paulirwin





