1. 搜索文件夹
@directory_path = "C:\\test\\"
if File.directory? @directory_path
Dir.foreach(@directory_path) do |file|
if file!="." and file!=".." and file!=".svn" and (File.directory?(@directory_path+file))
puts file
end
end
end
2.搜索文件
Find.find("C:\\test\\dir1") do |path|
if FileTest.directory?(path)
if File.basename(path)[0] == ?.
Find.prune
else
next
end
else
puts "Filename : " + File.basename(path)
end
end