Ruby 遍历目录

2014-12-01 0 896
Ruby 遍历目录
 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

遇见资源网 ruby Ruby 遍历目录 http://www.ox520.com/16192.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务