Checking to See if a File Exists : exist « File Directory « Ruby
- Ruby
- File Directory
- exist
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