Powershell 为什么IO.Compression.ZipFile条目数与7zip GUI不匹配?

Powershell 为什么IO.Compression.ZipFile条目数与7zip GUI不匹配?,powershell,zip,system.io.compression,Powershell,Zip,System.io.compression,我试图通过计算像answer这样的压缩条目的数量来验证PowerShell中ZIP存档的内容 但是,7Zip GUI、gci、Entries.Count和7Zip CLI之间的结果不一致,例如: (Get-ChildItem -path $sourceFolder -Recurse | where { ! $_.PSIsContainer }).Count =77779个文件 [IO.Compression.ZipFile]::OpenRead($zipFile).Entries.Count

我试图通过计算像answer这样的压缩条目的数量来验证PowerShell中ZIP存档的内容

但是,7Zip GUI、gci、Entries.Count和7Zip CLI之间的结果不一致,例如:

(Get-ChildItem -path $sourceFolder -Recurse | where { ! $_.PSIsContainer }).Count
=77779个文件

[IO.Compression.ZipFile]::OpenRead($zipFile).Entries.Count
=77838项

&'c:\Program Files\7-Zip\7z.exe' l $zipFile
=77779个文件,59个文件夹,即77838个对象

但是59个文件夹的计数是错误的-7Zip GUI显示77779个文件和35726个文件夹


是否有办法从.Entries中排除文件夹?否则我可以像解析7z.exe l命令一样解析结果,但更喜欢本机方法

您可以进行自定义计数。。。如果条目仅指定文件夹,请跳过它:

($zip.entries.where({!$_.FullName.EndsWith('/')})).count

当您将每个目录解压缩到新目录时,您观察到了什么?将2与beyond compare等进行比较…谢谢-我不知道目录条目以“/”结尾,但这完全有道理