From: Mike Stok Date: 2001-03-05T07:30:59+09:00 Subject: [ruby-talk:11984] Re: File exist method On Mon, 5 Mar 2001, Paul Pladijs wrote: > > Is there a method or a simple way to check > if some file exist? > > Something like: > > File.exist? ("myFileName") If you grab the ri utility from www.pragmaticprogrammer.com then you can do something like this: [mike@ratdog mike]$ ri File ------------------------------------------------------------------------ class: File < IO ------------------------------------------------------------------------ A File is an abstraction of any file object accessible by the program and is closely associated with class IO, page 329. File includes the methods of module FileTest as class methods, allowing you to write (for example) File.exist?("foo"). If you like you can use irb to try things out e.g. [mike@ratdog mike]$ irb irb(main):001:0> File.exist?('/boot/vmlinuz') true irb(main):002:0> File.exist?('/lotto/winning-numbers') false Hope this helps, Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA | Fingerprint 0570 71CD 6790 7C28 3D60 stok@colltech.com (CT - work) | 75D2 9EC4 C1C0 0599 13DA