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

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: IcSharpCode.sharpziplib.zip erstellen Sie ZIP mit Verzeichniseintrag. "Eintrag kann keine Daten haben"

by Anonymous » 05 Mar 2025, 07:53

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?

Top