I want to detects directories im my computers.but when I write below code , Ruby just give me "." and "..".
Dir.foreach("c:/windows") do |i|
puts i if File.directory(i)
end
please help me. thanks
Your code seems to work fine, except File.directory(i) should be File.directory?(i)
Dir.foreach("/mnt/tmp") do |i|
puts i if File.directory?(i)
end
=>
.
..
majic
Dropbox
if -d i is not even valid Ruby.
.and the previous directory shortcuts.., but nothing else. Are you sure the system you're on is able to read the C:/ partition correctly?