我在c#解决方案中使用DotNetZip来检查zip文件的内容(当前使用v1.13.3)。由于某些原因,为各种ZipEntry返回的文件属性无效。我正在获得带有大负数(例如-211877848)的奇怪属性。在没有意义的属性中设置了位。
string filePath = @"C:\standard_skin.zip";
Console.WriteLine("Known Attributes: {0} {1}", KnownFileAttributes.ToString(), ((int)KnownFileAttributes).ToBitString());
using (ZipFile zip = ZipFile.Read(filePath))
{
foreach (ZipEntry zipEntry in zip.Entries)
{
FileAttributes zipAttributes = zipEntry.Attributes;
if ((zipAttributes & ~KnownFileAttributes) != 0)
{
Console.Write("*** ");
}
Console.WriteLine("Entry: {0}; Attributes: {1}; Bad Attributes: {2}; Known Attributes: {3} {4}", zipEntry.FileName, zipAttributes.ToString(), ((int)((zipAttributes & ~KnownFileAttributes))).ToBitString(), ((int)(zipAttributes & KnownFileAttributes)).ToBitString(), ((zipAttributes & KnownFileAttributes)).ToString());
}
}
运行上面的代码时,我得到这样的输出:
Known Attributes: ReadOnly, Hidden, System, Directory, Archive 00000000000000000000000000110111
*** Entry: dialog_button_border/bottom.png; Attributes: -2118778848; Bad Attributes: 10000001101101100000000000000000; Known Attributes: 00000000000000000000000000100000 Archive
*** Entry: dialog_button_border/bottomleft.png; Attributes: -2118778848; Bad Attributes: 10000001101101100000000000000000; Known Attributes: 00000000000000000000000000100000 Archive
这里是所使用的zip文件的链接: https://drive.google.com/open?id=18BoKRrPzfz6fKqItlrWVgY6P3FtMvrAT