Ruby 遍历目录

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

 require 'find'
 
 def fileWalk(path)
  Find.find(path) do |f|  
      type = "File" if File.file?(f)
      type  = "Dir " if File.directory?(f)
        if type != "File" && type != "Dir "
          type = "   ?"
        end
    puts "#{type}: #{f}"  
  end  
end

fileWalk('C:\Ruby\doc') #put whatever folder here