Proof if a File exsists

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

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:

http://ruby-doc.org/

robert

On 7/31/06, Jonathan H. [email protected] 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs