Deleting a non empty directory

Hi, I am getting an exception when I use Dir.delete on a non empty
directory.
What should I do to remove a non empty directory?

Thanks,
Kostas

···

--
Posted via http://www.ruby-forum.com/.

Use Dir.each to iterate over the items in the dir, and call
File.delete on them. Then call Dir.delete.

···

On Jun 18, 1:32 pm, Kostas Zoumbatianos <zoumbatia...@gmail.com> wrote:

Hi, I am getting an exception when I use Dir.delete on a non empty
directory.
What should I do to remove a non empty directory?

Thanks,
Kostas

--
Posted viahttp://www.ruby-forum.com/.

Or use FileUtils::rm_rf:

http://www.ruby-doc.org/core/classes/FileUtils.html#M004368

Be careful though. :wink:

b

···

On Jun 18, 8:28 am, Kaldrenon <kaldre...@gmail.com> wrote:

On Jun 18, 1:32 pm, Kostas Zoumbatianos <zoumbatia...@gmail.com> > wrote:

> Hi, I am getting an exception when I use Dir.delete on a non empty
> directory.
> What should I do to remove a non empty directory?

> Thanks,
> Kostas

> --
> Posted viahttp://www.ruby-forum.com/.

Use Dir.each to iterate over the items in the dir, and call
File.delete on them. Then call Dir.delete.

bmunat@gmail.com wrote:

···

On Jun 18, 8:28 am, Kaldrenon <kaldre...@gmail.com> wrote:

> --
> Posted viahttp://www.ruby-forum.com/.

Use Dir.each to iterate over the items in the dir, and call
File.delete on them. Then call Dir.delete.

Or use FileUtils::rm_rf:

http://www.ruby-doc.org/core/classes/FileUtils.html#M004368

Be careful though. :wink:

b

Thanks a lot!

--
Posted via http://www.ruby-forum.com/\.