回复 5# 小白龙 - try {
- # 文件名是case-sensitive
- Add-Type -AssemblyName System.IO.Compression.FileSystem -ErrorAction Stop
- $archive = [System.IO.Compression.ZipFile]::Open('.\b.zip', 'Read')
- $xmldoc = New-Object System.Xml.XmlDocument
- foreach ($entry in $archive.Entries) {
- if ($entry.FullName.EndsWith('.xml', [System.StringComparison]::OrdinalIgnoreCase)) {
- $stream = $entry.Open()
- $xmldoc.Load($stream)
- $xmldoc.package.metadata.version
- $stream.Close()
- }
- }
- } finally {
- if ($stream) {
- $stream.Close()
- }
- if ($archive) {
- $archive.Dispose()
- }
- }
- trap {}
复制代码
|