# Finding current drive

**URL:** <https://www.ruby-forum.com/t/finding-current-drive/137708>\
**Category:** Ruby\
**Created:** [May 15, 2008, 3:44pm UTC](https://www.ruby-forum.com/t/finding-current-drive/137708 "2008-05-15T15:44:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![parvg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@parvg](https://www.ruby-forum.com/u/parvg)\
**Post date:** [May 15, 2008, 3:44pm UTC](https://www.ruby-forum.com/t/finding-current-drive/137708/1 "2008-05-15T15:44:50Z")

</div>

hello,

Is there a way to find out under what drive my current/active file is?

if the .rb file i’m working on is sitting in c:/code/ruby/myfile.rb, i  
would like to find a way to retrieve “c”.

Thanks!

---

<div class="post-metadata">

**Author:** ![parvg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@parvg](https://www.ruby-forum.com/u/parvg)\
**Post date:** [May 15, 2008, 3:56pm UTC](https://www.ruby-forum.com/t/finding-current-drive/137708/2 "2008-05-15T15:56:12Z")

</div>

On May 15, 3:44 pm, “Parv G.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a way to find out under what drive my current/active file is?
> 
> if the .rb file i’m working on is sitting in c:/code/ruby/myfile.rb, i  
> would like to find a way to retrieve “c”.

Dir.pwd - if you want to find out what the “working directory” is,  
i.e. where the user was when he launched the script.

File.expand\_path($0) - if you want to find what script was run from  
the command line.

File.expand\_path( **FILE** ) - if you want to find the path to the  
current script file.

Lars

---

<div class="post-metadata">

**Author:** ![parvg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@parvg](https://www.ruby-forum.com/u/parvg)\
**Post date:** [May 15, 2008, 4:07pm UTC](https://www.ruby-forum.com/t/finding-current-drive/137708/3 "2008-05-15T16:07:38Z")

</div>

> Dir.pwd - if you want to find out what the “working directory” is,  
> i.e. where the user was when he launched the script.
> 
> File.expand\_path($0) - if you want to find what script was run from  
> the command line.
> 
> File.expand\_path( **FILE** ) - if you want to find the path to the  
> current script file.
> 
> Lars

thanks! i could work with these.

Parv

---

<div class="post-metadata">

**Author:** ![parvg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@parvg](https://www.ruby-forum.com/u/parvg)\
**Post date:** [May 15, 2008, 4:35pm UTC](https://www.ruby-forum.com/t/finding-current-drive/137708/4 "2008-05-15T16:35:29Z")

</div>

unsuscribe

* * *

Si vous n’etes pas le destinataire designe de ce message ou une personne  
autorisee a l’utiliser, toute distribution, copie, publication ou usage  
a quelques fins que ce soit des informations dans ce message sont  
interdits. Merci d’informer immediatement l’expediteur par messagerie,  
et, de detruire ce message.  
This e-mail is confidential. If you are not the addressee or an  
authorized recipient of this message, any distribution, copying,  
publication or use of this information for any purpose is prohibited.  
Please notify the sender immediately by e-mail and then delete this  
message.

* * *
