Directories in a zip file #92

Open
opened 2026-01-29 22:06:28 +00:00 by claunia · 0 comments
Owner

Originally created by @glcjr on GitHub (Apr 2, 2016).

Is it possible with the reader to process a zip file that has images and then subdirectories with more images?

What I'm trying to do is to read a zipfile and put the images in a List and I want to open any subdirectories in the zip file and add those images to my list as well.

I'm not sure how to open a directory within the zip file for this.

Basically I'm trying to create a little picture viewer program where I click next to go through the List and see the pictures display in a picturebox. Seemed simple but the subdirectories have stymied me.

This is what I've come up with so far. Just in case what I think will work is wrong...

        using (Stream stream = File.OpenRead(filepath))
        {
            var reader = ReaderFactory.Open(stream);
            while (reader.MoveToNextEntry())
            {
                if (reader.Entry.IsDirectory)
                {

                }
                else
                {
                    System.Drawing.Image img = System.Drawing.Image.FromStream(reader.OpenEntryStream());
                    book.addImage(img);
                }
            }
        }

book is just an object of a class I created with the List declared inside

Originally created by @glcjr on GitHub (Apr 2, 2016). Is it possible with the reader to process a zip file that has images and then subdirectories with more images? What I'm trying to do is to read a zipfile and put the images in a List<Image> and I want to open any subdirectories in the zip file and add those images to my list as well. I'm not sure how to open a directory within the zip file for this. Basically I'm trying to create a little picture viewer program where I click next to go through the List and see the pictures display in a picturebox. Seemed simple but the subdirectories have stymied me. This is what I've come up with so far. Just in case what I think will work is wrong... ``` using (Stream stream = File.OpenRead(filepath)) { var reader = ReaderFactory.Open(stream); while (reader.MoveToNextEntry()) { if (reader.Entry.IsDirectory) { } else { System.Drawing.Image img = System.Drawing.Image.FromStream(reader.OpenEntryStream()); book.addImage(img); } } } ``` book is just an object of a class I created with the List declared inside
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#92