I want to create a sub-directory of a directory that does not exist like: /foo/bar
I tried:
Dir.mkdir("foo/bar")
but this does not work.
If you are trying to create a directory and its parent directories, you want to use FileUtils.mkdir_p
instead.
Is this what you're looking for?
require 'fileutils'
FileUtils.mkpath('/foo/bar')
mkpath
is an alias of mkdir_p
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With