From: Robert Klemme Date: 2004-08-05T18:16:27+09:00 Subject: Re: open files in other directories "Matthew Margolis" schrieb im Newsbeitrag news:41119195.7010502@wisc.edu... > I am trying to figure out how to open up a text file in a subdirectory > of my programs main directory. The file I want is in the subdirectory > labeled text. I get a "Permission denied - text/" message when > attempting to run the code found below. > > campershash = Hash.new > Dir.entries("text").each do |textfilename| > campershash["#{textfilename.chop.chop.chop.chop}"] = > File.open("text/" + "#{textfilename}") { |f| f.gets(nil) } > end campershash = {} Dir.entries("text").each do |textfilename| key = textfilename[0...-4] and campershash[key] = File.read( File.join("text", textfilename) ) end robert