使用 dotnetzip 列出文件

发布于 2024-09-08 11:42:01 字数 1170 浏览 1 评论 0原文

using (ZipFile zip = ZipFile.Read(ExistingZipFile))  
  {  
    foreach (ZipEntry e in zip)  
    {  
      if (header)  
      {  
        System.Console.WriteLine("Zipfile: {0}", zip.Name);  
        if ((zip.Comment != null) && (zip.Comment != ""))   
          System.Console.WriteLine("Comment: {0}", zip.Comment);  
        System.Console.WriteLine("\n{1,-22} {2,8}  {3,5}   {4,8}  {5,3} {0}",  
                                 "Filename", "Modified", "Size", "Ratio", "Packed", "pw?");  
        System.Console.WriteLine(new System.String('-', 72));  
        header = false;  
      }  
      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");  

    }  
  }  

我正在使用上面的代码来打印 zip 文件内的苍蝇列表。有人可以告诉我这里的标题是什么吗?(​​我使用 c# 作为语言在 asp.net 代码中编写此内容,但这显示为错误)。请帮忙。

using (ZipFile zip = ZipFile.Read(ExistingZipFile))  
  {  
    foreach (ZipEntry e in zip)  
    {  
      if (header)  
      {  
        System.Console.WriteLine("Zipfile: {0}", zip.Name);  
        if ((zip.Comment != null) && (zip.Comment != ""))   
          System.Console.WriteLine("Comment: {0}", zip.Comment);  
        System.Console.WriteLine("\n{1,-22} {2,8}  {3,5}   {4,8}  {5,3} {0}",  
                                 "Filename", "Modified", "Size", "Ratio", "Packed", "pw?");  
        System.Console.WriteLine(new System.String('-', 72));  
        header = false;  
      }  
      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");  

    }  
  }  

I am using above code to print list of flies inside zip file.can somebody tell me what is header over here.(I a writing this in asp.net code behind using c# as language,but this showing as error).Please help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

财迷小姐 2024-09-15 11:42:01

阅读您的评论后,我想说您需要声明并初始化标头变量。像这样的东西:

using (ZipFile zip = ZipFile.Read(ExistingZipFile))  
  {  
    bool header = true;
    foreach (ZipEntry e in zip)  
    {  
      if (header)  
...

After reading your comment i would say you need to declare and initialize the header variable. Something like this:

using (ZipFile zip = ZipFile.Read(ExistingZipFile))  
  {  
    bool header = true;
    foreach (ZipEntry e in zip)  
    {  
      if (header)  
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文