From: Brian Candler Date: 2007-02-09T23:46:21+09:00 Subject: Re: File.open () Errno::ENOTDIR On Fri, Feb 09, 2007 at 11:12:46PM +0900, Rebhan, Gilbert wrote: > i have a problem with File.open = > > File.open(SRCDIR<<'/'< |f| > mymethod(x) > end Warning: string1 << string2 modifies string1 by adding the contents of string2. So here you are modifying SRCDIR, which is probably not what you want, especially if you're going round this in a loop. SRCDIR='/tmp' puts SRCDIR<<'/bar' # '/tmp/bar' puts SRCDIR # '/tmp/bar' Use + to concatenate two strings and get the result as a third, newly-created string. > How to get the Dirname Dir.entries(SRCDIR).sort[2] into the string > for method File.open ? File.open(SRCDIR + '/' + Dir.entries(SRCDIR).sort[2] + '/foobar.TXT') or File.open("#{SRCDIR}/#{Dir.entries(SRCDIR).sort[2]}/foobar.TXT")