From: camenix Date: 2006-10-22T16:50:11+09:00 Subject: Re: What is wrong with my code > Hi folks, > > I write two srcipts to check files in a given directory. Version 1 uses > regular expression and works but I cann't find the size for each file. > Version 2 uses Ruby built-in File.file? method but it doesn't work at > all. I wonder what is going on with my scripts? > > Thank you, > > Li > > #######Version 1: > > path='c:\path\to\folder' > Dir.open(path).each do |file| > if file=~/(\w+|d+).(\d{3,})/ > puts file > puts File.size(file)# this line doesn't work > file_number+=1 > end > end > > puts > puts 'Files',path > puts 'File number',file_number > > #######Version2 > path='c:\path\to\folder' > Dir.open(path).each do |file| > if File.file?(file) > puts file > puts File.size(file) > file_number+=1 > end > end > > puts > puts 'Files',path > puts 'File number',file_number > > -- > Posted via http://www.ruby-forum.com/. Use File.extend_path to convert path to absolute path.I think there is something wrong with the file.