- 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
- #该片段来自于http://www.codesnippet.cn/detail/020520133118.html
来源: http://www.codesnippet.cn/detail/020520133118.html