From: "Marvin Gülker" Date: 2010-08-02T23:01:42+09:00 Subject: Re: Iteration through File.file? misses entries for which File.file?(entry) == true Kyle Barbour wrote: > def getFiles(dir) > pwdFiles = Array.new > > Dir.foreach(dir) do |entry| > pwdFiles.push(entry) if File.file?(entry) == true > end > end That can't work since Dir.foreach yields only the filenames of the files in the directory to the block, not the directory the files are actually in. So suppose you have: dir/my_file dir/my_second_file By calling Dir.foreach("dir") you'll get "my_file" and "my_second_file". Your File.file? statement then checks for the presence of the filenames in the current working directory -- where they don't reside. Solution: Append "dir" to the filename. def get_files(dir) pwd_files = Array.new Dir.foreach(dir) do |entry| path = File.join(dir, entry) pwd_files.push(path) if File.file?(path) end pwd_files end And please use snake_case for your method and variable names. Marvin -- Posted via http://www.ruby-forum.com/.