# Geeting full path name of a file

**URL:** <https://www.ruby-forum.com/t/geeting-full-path-name-of-a-file/122324>\
**Category:** Rails\
**Created:** [December 6, 2007, 5:01pm UTC](https://www.ruby-forum.com/t/geeting-full-path-name-of-a-file/122324 "2007-12-06T17:01:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jagan](https://www.ruby-forum.com/u/jagan)\
**Post date:** [December 6, 2007, 5:01pm UTC](https://www.ruby-forum.com/t/geeting-full-path-name-of-a-file/122324/1 "2007-12-06T17:01:43Z")

</div>

Hello all,

how can i get the full path name of a file.like i have file called  
“example.csv”. in "D " drive .

when i am using IE with rails i am geeting the full path name .but  
when i am using it with firefox i am just getting the filename. is  
there any way i could get the full path name

thanks  
Jagan

---

<div class="post-metadata">

**Author:** ![jagan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jagan](https://www.ruby-forum.com/u/jagan)\
**Post date:** [December 6, 2007, 9:04pm UTC](https://www.ruby-forum.com/t/geeting-full-path-name-of-a-file/122324/2 "2007-12-06T21:04:44Z")

</div>

What method are you currently using?

---

<div class="post-metadata">

**Author:** ![jagan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jagan](https://www.ruby-forum.com/u/jagan)\
**Post date:** [December 6, 2007, 9:14pm UTC](https://www.ruby-forum.com/t/geeting-full-path-name-of-a-file/122324/3 "2007-12-06T21:14:42Z")

</div>

Hi Matt,

I am not using any method for getting the path.As i select the file  
name in IE its prinitng the full path of the file as file name in IE  
where as in fire fox ,its not printing the fullpath when i am using  
the file name that i used in IE.is there any method in ruby which  
i can use in for getting the full path of the file

Thanks  
Jagan

---

<div class="post-metadata">

**Author:** ![jagan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jagan](https://www.ruby-forum.com/u/jagan)\
**Post date:** [June 25, 2008, 5:52pm UTC](https://www.ruby-forum.com/t/geeting-full-path-name-of-a-file/122324/4 "2008-06-25T17:52:33Z")

</div>

Jagan did you ever manage to work this out? I need to do the same thing

Thanks!

---

<div class="post-metadata">

**Author:** ![jagan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jagan](https://www.ruby-forum.com/u/jagan)\
**Post date:** [March 28, 2013, 11:17am UTC](https://www.ruby-forum.com/t/geeting-full-path-name-of-a-file/122324/5 "2013-03-28T11:17:00Z")

</div>

Don’t want to revive a 5 year old thread. But for those who came here  
looking for answers, this is how I got it:

require ‘pathname’  
filepath = some\_valid\_path  
Pathname.new(filepath).realpath.to\_s

The thing to note is that realpath expects the file to exist.

---

<div class="post-metadata">

**Author:** ![jagan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5ac83/32.png) [@jagan](https://www.ruby-forum.com/u/jagan)\
**Post date:** [December 6, 2007, 9:25pm UTC](https://www.ruby-forum.com/t/geeting-full-path-name-of-a-file/122324/6 "2007-12-06T21:25:15Z")

</div>

Is File.expand\_path(filename) what you’re looking for?

On Dec 6, 1:13 pm, “Jagan Mohan Jasti” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
