【问题标题】:listing files using dotnetzip使用 dotnetzip 列出文件
【发布时间】:2010-07-06 19:58:18
【问题描述】:
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 代码中编写此代码,但这显示为错误)。请帮忙。

【问题讨论】:

  • 标头是一个布尔值。你的错误是什么?
  • 它无法识别标题(它用红色下划线表示“当前上下文中不存在名称'标题')。
  • 我其实是dotnetzip.codeplex.com/…的代码
  • header 定义在哪里?您确定是在发布问题之前查找过它吗?

标签: c# dotnetzip


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多