# Saving files to harddrive

**URL:** <https://www.ruby-forum.com/t/saving-files-to-harddrive/124268>\
**Category:** Ruby\
**Created:** [December 27, 2007, 7:32am UTC](https://www.ruby-forum.com/t/saving-files-to-harddrive/124268 "2007-12-27T07:32:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Corbin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/838e76/32.png) [@Corbin\_S](https://www.ruby-forum.com/u/Corbin_S)\
**Post date:** [December 27, 2007, 7:32am UTC](https://www.ruby-forum.com/t/saving-files-to-harddrive/124268/1 "2007-12-27T07:32:10Z")

</div>

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 S.

---

<div class="post-metadata">

**Author:** ![Corbin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/838e76/32.png) [@Corbin\_S](https://www.ruby-forum.com/u/Corbin_S)\
**Post date:** [December 27, 2007, 8:40am UTC](https://www.ruby-forum.com/t/saving-files-to-harddrive/124268/2 "2007-12-27T08:40:35Z")

</div>

On Dec 27, 2007 5:30 PM, Corbin S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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
