- def traverse_dir(file_path)
- if File.directory? file_path
- Dir.foreach(file_path) do |file|
- if file !="." and file !=".."
- traverse_dir(file_path+"/"+file)
- end
- end
- else
- puts "File:#{File.basename(file_path)}, Size:#{File.size(file_path)}"
- end
- end
- traverse_dir('D:/apache-tomcat')
- #该片段来自于http://www.codesnippet.cn/detail/250320132536.html
来源: http://www.codesnippet.cn/detail/250320132536.html