Page 1 of 1

IcSharpCode.sharpziplib.zip erstellen Sie ZIP mit Verzeichniseintrag. "Eintrag kann keine Daten haben"

Posted: 05 Mar 2025, 07:53
by Anonymous
Ich habe ein Problem damit, ein Archiv zu erstellen und einen Verzeichniseintrag hinzuzufügen. Mein Code sieht wie folgt aus: < /p>
using (var zip = ZipFile.Create(zipPath))
{
if (!string.IsNullOrEmpty(password))
{
zip.ZipCryptoEncoding = Encoding.UTF8;
zip.Password = password;
}
zip.UseZip64 = UseZip64.Dynamic;

var EntryFactory = new ZipEntryFactory();
ZipEntry dirEntry = EntryFactory.MakeDirectoryEntry(dirPath);
dirEntry.DateTime = DateTime.Now;
dirEntry.IsUnicodeText = true;

if (!string.IsNullOrEmpty(password))
{
dirEntry.AESKeySize = 256;
}
if (!compression)
{
dirEntry.CompressionMethod = CompressionMethod.Stored;
}
if (compression)
{
dirEntry.CompressionMethod = CompressionMethod.Deflated;
}
zip.BeginUpdate();
zip.Add(dirEntry);
zip.CommitUpdate();

}
< /code>
Es wird eine Ausnahme "Eintrag können keine Daten haben." Gibt es eine Möglichkeit, eine ZIP -Datei Verzeichniseintrag hinzuzufügen?