From: Zhao Yi Date: 2009-01-16T09:41:00+09:00 Subject: Re: How to create a file Robert Klemme wrote: > On 13.01.2009 08:09, Zhao Yi wrote: >> I use this code to write to a file: File.new(@FILE_NAME,"w"). If the >> file name doesn't exist, I will get "No such file" error. How can I >> create the file if it doesn't exist? > > I cannot reproduce this behavior. Did you make sure that the directory > exists where you want to create your file? In case not you probably > want to have a look at FileUtils.mkdir_p: > > http://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/classes/FileUtils.html#M000676 > > Cheers > > robert The directory doesn't exist, that's the problem. thanks. -- Posted via http://www.ruby-forum.com/.