[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Fast check if files exist

Gavin Kistner

8/24/2007 8:08:00 PM

From: eggie5 [mailto:eggie5@gmail.com]
> I have list (array) of file names in the form:
>
> What's the fastest way I can check if these files exist in a given
> directory?

Dir.chdir( source_directory ) do
my_array.each do |file_name|
if File.exist?( file_name )
...
else
...
end
end
end


1 Answer

eggie5

8/24/2007 9:27:00 PM

0

On Aug 24, 1:08 pm, "Gavin Kistner" <gavin.kist...@anark.com> wrote:
> From: eggie5 [mailto:egg...@gmail.com]
>
> > I have list (array) of file names in the form:
>
> > What's the fastest way I can check if these files exist in a given
> > directory?
>
> Dir.chdir( source_directory ) do
> my_array.each do |file_name|
> if File.exist?( file_name )
> ...
> else
> ...
> end
> end
> end

Thanks, I like this a lot.