答案1
使用带有 .NET 4.5 或更高版本的 PowerShell,您可以在新的或现有的 zip 文件中手动创建一个空目录:https://stackoverflow.com/a/52395011/1507941
- 打开 PowerShell 提示符。
- 输入以下命令,根据需要替换文件名:
Add-Type -Assembly 'System.IO.Compression'
Add-Type -Assembly 'System.IO.Compression.FileSystem'
# Must be used for relative file locations with .NET functions instead of Set-Location:
[System.IO.Directory]::SetCurrentDirectory('.\Desktop')
# Replace "Update" with "Create" if creating a new zip file
$zip = [System.IO.Compression.ZipFile]::Open('archive.zip', [System.IO.Compression.ZipArchiveMode]::Update)
# Get folder to be created
$existingFile = Get-Item 'Empty Folder'
# Create directory copying its attributes
$entry = $zip.CreateEntry($existingFile.Name + '/')
# Set modified date manually to match empty folder you wanted to add
$entry.LastWriteTime = $existingFile.LastWriteTime
# Closes file and allows it to be opened elsewhere
$zip.Dispose()
请随意查看这个库的文档:https://learn.microsoft.com/en-us/dotnet/api/system.io.compression