Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:33:58+00:00 2026-06-02T08:33:58+00:00

I have a zip file which on first ‘level’ contains only directory. Something like:

  • 0

I have a zip file which on first ‘level’ contains only directory. Something like:

some_file.zip

/ Opened file (level 1)

-> Directory/

/ level 2

-> file.txt

-> file2.txt

Can somebody write code how to cd to a Directory\ and list all entries?

I have written code but it doesnt work:

require 'zip/zipfilesystem'

Zip::ZipFile.open("./some_file.zip") do |zipfile|
  zipfile.each_with_index do |file, index|
    puts "inspect file == #{file.inspect}"
    puts "entries == #{ zipfile.entries }"
    entries = zipfile.entries
    puts "zipfile.open file #{ zipfile.read(file) }"
  end
end

PS I use rubyzip https://github.com/aussiegeek/rubyzip

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:34:00+00:00Added an answer on June 2, 2026 at 8:34 am

    Your code seems a bit too complicated. Suppose you have a zip file like this:

    $ mkdir data
    $ cd data
    $ touch foo bar baz
    $ cd ..
    $ zip -r data.zip data/
    

    Then you can list the contents of the zip file using the entries method like in the following example:

    require 'zip/zip'
    
    zip = Zip::ZipFile.open('data.zip')
    zip.entries.each do |entry|
      puts entry
    end
    

    This little example produces the following output:

    data/
    data/bar
    data/baz
    data/foo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a zip file which contains the following directory structure: dir1\dir2\dir3a dir1\dir2\dir3b I'm
I have .zip file which contain csv data. I am reading .zip file using
In one of my git projects, I have a zip file which bundles a
I have a file with addresses in which some addresses have the city zip
I have a zip file which can contain any number of zipfiles inside it
I have a war file which does not contains manifest not even META-INF folder.
I have zip file and I want to know which library can handle it?
I have always wondered about this. So many application setups have a zip file
I have found that creating a zip file using the Zip task provided by
I have inherited some code (from zip file) from a developer and git initialzed,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.