Dir.foreach(“bad”) do |f|
puts “#{f}: #{File.size f}”
end
Each filename in the directory “bad” is displayed along with the file
size.
I know the file.size works because I tried it with an static name and
displayed fine.
the error I got
============
lib/dir_test.rb:6:in size': No such file or directory - IMG_0964.jpg (Errno::ENOENT) from lib/dir_test.rb:6 from lib/dir_test.rb:5:inforeach’
from lib/dir_test.rb:5
in the first place, you wouldn’t need to add the ‘bad/’. I was
originally
going to reply to suggest adding it, but then I though .foreach() would
do
that for ya. Guess not.
Regards,
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.