Saving files to harddrive

C

Corbin Smith

I'm wondering if it's possible to save a file to a harddrive with Ruby.
I've googled it a few times but I never
get what I need. I know I can 'write' to a file, but it doesn't actually
write to it on the harddrive, just during
that instance.

If anyone knows whether or not this is possible, that'd be great.

Thanks,
Corbin Smith
 
M

Mikel Lindsaar

I'm wondering if it's possible to save a file to a harddrive with Ruby.

Of course

$ irb
irb> text = "Hello world\n"
=> "Hello world\n"
irb> File.open("mytestfile.txt", "w") { |f| f.write(text) }
=> 12
irb> exit
$ cat mytestfile.txt
Hello World
$

That is "saving a file"


Mikel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top