Checking to See if a File Exists : exist « File Directory « Ruby






Checking to See if a File Exists


filename = 'a_file.txt'
File.file? filename                        # => false

require 'fileutils'
FileUtils.touch(filename)
File.file? filename                        # => true

 








Related examples in the same category

1.Checking If a File Exists
2.Create class to wrap File.exist and File.new method
3.Check to see if a dicectory exists