Get a list of the files and directories within a specific directory using Dir.entries:
puts Dir.entries("c:/").join(' ')
Dir.entries returns an array with all the entries within the specified directory.
Dir.foreach provides the same feature, but as an iterator:
Dir.foreach("c:/") do |entry|
puts entry
end
An even more concise way of getting directory listings is by using Dir's class array method:
puts Dir["c:/*"]
Here, each entry is returned as an absolute filename.
You could take this process a step further and be a little more platform independent:
Dir[File.join(File::SEPARATOR, 'c:/', 'test', '*')]