From: "Aurélien AMILIN" Date: 2010-04-04T23:12:45+09:00 Subject: Re: Reading contents of all files from a Directory --0016e6d6456052a04d048369ceb7 Content-Type: text/plain; charset=ISO-8859-1 First you should use file wich contain the filename of your file instead of "file" which is a string Then try to open your file with the r option not a+ (a+ means you place the cursor at the end of the file to append some content while r is for reading so the cursor is placed at the beginning of the file) so : File.open(file,"r") instead of : File.open("file","a+") 2010/4/4 Hawksury Gear > > If it is only for output purposes, we can actually do it in one line: > > > > puts Dir["K:/test/*"].map {|f| File.read f} > > > > Note: this is not necessarily efficient nor safe (just think of 3GB > > files...). > > > > Kind regards > > > > robert > > Many Thanks for replying robert, I am trying to print the contents of > each file > in the following way,It isn't giving me any error message but it is not > showing any output, Could you please help. > > arr= Dir.open("K:/test").entries > arr.each do| file | > File.open("file","a+") do |fd| > fd.each {|line| print line} > end > > Regards, > Gear > -- > Posted via http://www.ruby-forum.com/. > > --0016e6d6456052a04d048369ceb7--