From: charlie bowman Date: 2006-01-31T02:09:08+09:00 Subject: Re: check for and if not there, create direcory and file irb(main):002:0> Dir.mkdir(".timeclock") won't the above faile once the directory is created. I need to run a check each time the application is ran. Matthew Smillie wrote: > On Jan 30, 2006, at 16:39, charlie bowman wrote: > >> >> I'm making a little app that requires this folder .timeclock/filename >> >> The first time the app runs I would like it to check to see if the >> folder and file are there and if not, create them. Everything I've >> tried >> crashes if the folder isn't there. Thanks for any help! > > These methods might help you out with creating the directory: > > irb(main):001:0> File.exist?(".timeclock") > => false > irb(main):002:0> Dir.mkdir(".timeclock") > => 0 > irb(main):003:0> File.exist?(".timeclock") > => true > irb(main):004:0> File.directory?(".timeclock") > => true > > From there you should be able to just open .timeclock/new_file as > one normally would. > > matthew smillie. -- Posted via http://www.ruby-forum.com/.