1

我正在使用iconic.dll文件从压缩文件(.zip 文件扩展名)中读取数据

请检查我下面的代码

string zippath = txtFilePath.Text.Trim() + "\\" + foldername + ".zip";
ArrayList arrFiles = new ArrayList();
using (ZipFile zip = ZipFile.Read(enrollment))
{
     foreach (ZipEntry e1 in zip)
     {
       arrFiles.Add(e1.ToString());
     }
}

foreach (string path in arrFiles)
{
   Image img1 = Image.FromFile(path);  //geting error on this line
   imageList.Images.Add(getThumbnaiImage(imageList.ImageSize.Width, img1));
}

如何从压缩文件夹中读取图像文件?

4

2 回答 2

1

试试这个 :

  using (ZipFile zip = ZipFile.Read(enrollment))
{
    ZipEntry entry = zip["Image.bmp"];
    entry.Extract(outputStream);
}

您还可以在图片框中显示您的图像:

PictureBox pb = new PictureBox();
        pb.Location = new Point(100, 100);
        pb.SizeMode = PictureBoxSizeMode.Zoom;
        var bmp = new Bitmap(outputStream);
        pb.Image = bmp;
        this.Controls.Add(pb);
于 2012-11-03T11:58:06.093 回答
1

这似乎是解决方案:

  using (ZipFile zip = ZipFile.Read(enrollment))
        {

            foreach (ZipEntry e1 in zip)
            {

                    CrcCalculatorStream reader = e1.OpenReader();
                    MemoryStream memstream = new MemoryStream();
                    reader.CopyTo(memstream);
                    byte[] bytes = memstream.ToArray();
                    Image img1 = Image.FromStream(memstream);
                    imageList.Images.Add(getThumbnaiImage(imageList.ImageSize.Width, img1));


            }
        }
于 2012-11-05T09:29:34.783 回答