We can delete a file using the File.delete method.
Working with Files
When working with files, it is important to first check if the file exists in order to prevent an error.
The file? method provides an easy way of checking if the file exists.
File.open(“test.txt”) if File.file?(“text.txt”)
The code above tests whether a file exists before opening it.
CLICK ON THE BUTTON BELOW TO GO TO THE RUBY MAIN COURSE PAGE.
© License: All Rights Reserved
CONTACT HOLLA TECH – LEARN SUPPORT