[英]How to get file properties (Created and Modified) from files in a .NET ZipPackage?
I'm using the ZipPackage-class in .NET to read and write zip-files. 我在.NET中使用ZipPackage类读取和写入zip文件。 But how do I get basic file properties from files within a zip-package?
但是,如何从zip包中的文件中获取基本文件属性? I'm specifically looking for the date-times Created and Modified.
我特别在寻找创建和修改的日期时间。 I would prefer to not depend on a external lib of course, but it may be unavoidable...
我当然不希望依赖于外部库,但这可能是不可避免的...
I have never used the ZipPackage class, so I can't comment on that. 我从未使用过ZipPackage类,因此无法对此发表评论。 But using other libraries, this should be easily possible.
但是使用其他库,这应该很容易实现。 Eg using DotNetZip , the following snippet extracts information about all entries (files) of a zip archive:
例如,使用DotNetZip ,以下代码段提取有关zip存档的所有条目(文件)的信息:
List entries in a zip. 列出邮编中的条目。 List all the entries in a zip file:
列出zip文件中的所有条目:
using (ZipFile zip = ZipFile.Read(ExistingZipFile))
{
foreach (ZipEntry e in zip)
{
System.Console.WriteLine("{1,-22} {2,8} {3,5:F0}% {4,8} {5,3} {0}",
e.FileName,
e.LastModified.ToString("yyyy-MM-dd HH:mm:ss"),
e.UncompressedSize,
e.CompressionRatio,
e.CompressedSize,
(e.UsesEncryption) ? "Y" : "N");
}
}
(Class ZipEntry
has other properties such as CreationTime, AccessdTime, etc.). (类
ZipEntry
具有其他属性,例如CreationTime,AccessdTime等)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.