[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Saving files to harddrive

Corbin Smith

12/27/2007 6:29:00 AM

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

--
Using Opera's revolutionary e-mail client: http://www.opera...
1 Answer

Mikel Lindsaar

12/27/2007 7:40:00 AM

0

On Dec 27, 2007 5:30 PM, Corbin Smith <brinco.cs@gmail.com> wrote:
> 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