# Proof if a File exsists

**URL:** <https://www.ruby-forum.com/t/proof-if-a-file-exsists/100598>\
**Category:** Ruby\
**Created:** [July 30, 2006, 6:17pm UTC](https://www.ruby-forum.com/t/proof-if-a-file-exsists/100598 "2006-07-30T18:17:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df705f/32.png) [@jah](https://www.ruby-forum.com/u/jah)\
**Post date:** [July 30, 2006, 6:17pm UTC](https://www.ruby-forum.com/t/proof-if-a-file-exsists/100598/1 "2006-07-30T18:17:18Z")

</div>

Hi,

I want to proof if a File exsist. I just realize this by

if(Dir.glob(file).length == 0)

But I think there should be a better possibiliti like  
File.exsists?(file)

Jonathan

---

<div class="post-metadata">

**Author:** ![jah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df705f/32.png) [@jah](https://www.ruby-forum.com/u/jah)\
**Post date:** [July 30, 2006, 6:24pm UTC](https://www.ruby-forum.com/t/proof-if-a-file-exsists/100598/2 "2006-07-30T18:24:08Z")

</div>

Jonathan H. wrote:

> Hi,
> 
> I want to proof if a File exsist. I just realize this by
> 
> if(Dir.glob(file).length == 0)
> 
> But I think there should be a better possibiliti like File.exsists?(file)

You’re close. Check the docs:

> **[Ruby-Doc.org: Documenting the Ruby Language](https://ruby-doc.org/)**
>
> Fast, searchable Ruby documentation for core and standard libraries. Plus, links to tutorials, guides, books, and related sites.

```
robert

```

---

<div class="post-metadata">

**Author:** ![jah](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df705f/32.png) [@jah](https://www.ruby-forum.com/u/jah)\
**Post date:** [July 31, 2006, 5:43am UTC](https://www.ruby-forum.com/t/proof-if-a-file-exsists/100598/3 "2006-07-31T05:43:28Z")

</div>

On 7/31/06, Jonathan H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> I want to proof if a File exsist. I just realize this by
> 
> if(Dir.glob(file).length == 0)
> 
> But I think there should be a better possibiliti like File.exsists?(file)

Actually it’s File.exist?(file). There’s a whole slew of these file  
tests, such as File.directory?, File.readable?, File.writable? and so  
on. Have a look at the documentation here:

[http://www.ruby-doc.org/core/classes/FileTest.html](http://www.ruby-doc.org/core/classes/FileTest.html)
