Create a dir, create a file in it, and delete the file, remove the folder : Dir.rmdir « File Directory « Ruby






Create a dir, create a file in it, and delete the file, remove the folder

Dir.mkdir("temp")                 # Create a directory
File.open("temp/f", "w") {}       # Create a file in it
File.open("temp/g", "w") {}       # Create another one
File.delete(*Dir["temp/*"])       # Delete all files in the directory
Dir.rmdir("temp")                 # Delete the directory

 








Related examples in the same category