how to create a folder with Ruby

For general discussion related FlowStone
Post Reply
User avatar
jjs
Posts: 142
Joined: Thu Jun 09, 2011 12:15 pm

how to create a folder with Ruby

Post by jjs »

Hi,

it's been a while.
But does anybody knows how to create a folder?

To get to a folder is easy but to create one?

For example a user puts in a name, then i want to create a folder in the My Documents folder.

I tried something like this:
begin
Dir::mkdir(directory_name)
rescue
puts "the directory already exists"
end

but....
anyone ?

thanks a lot for your help :)
User avatar
jjs
Posts: 142
Joined: Thu Jun 09, 2011 12:15 pm

Re: how to create a folder with Ruby

Post by jjs »

found a solution that fits probably good enough

viewtopic.php?f=2&t=1354&p=5002&hilit=create+folder#p5002

thanks to Trog
Tronic
Posts: 539
Joined: Wed Dec 21, 2011 12:59 pm

Re: how to create a folder with Ruby

Post by Tronic »

Code: Select all

directory_name = "name"
Dir.mkdir(directory_name) unless File.exists?(directory_name)
User avatar
jjs
Posts: 142
Joined: Thu Jun 09, 2011 12:15 pm

Re: how to create a folder with Ruby

Post by jjs »

Thanks Tronic !
I will give that a try.
Post Reply