From: Robert Klemme Date: 2009-03-17T03:27:35+09:00 Subject: Re: handling many files inside dir On 16.03.2009 15:22, Bary Buz wrote: > im trying to process a directory that contains many text files. I want > to read each file, store the text inside file and then move to the next > file. I used the following code but at the end i get an error about > Permission Denied. Can someone tell me what im doing wrong. Where do you get that error? Can you provide the stacktrace and indicate where that is in the script? > #get list of files > > basedir = "C:/rubyfolder" > Dir.chdir(basedir) > Dir.open(basedir) do |dir| This won't work as soon as basedir is a relative path! > dir.each do |file| > x = file > myfile = File.open(x, "r") > x.close > dataclass = Manipulate.new(myfile) > end > end > > thanks in advance See also lasitha's excellent remarks. Cheers robert