array = ["Cliebnt.rb", "Clientversbion.txt", "filbe1.rb", "UpdateSebrver.rb", "ttesbt.rb", "filbe2.txt", "readebr.rb", "Actualbversion.txt"]
print a = array.size
a.times do
print b = array.pop
sleep 2
Dir.chdir(File.dirname(File.new (b)))
end
返回
"txtfile1.rb:7:in `initialize': No such file or directory @ rb_sysopen - Actualbversion.txt (Errno::ENOENT)"
如何解决?
答案 0 :(得分:0)
Dir.chdir(__dir__) do |path|
array.each { |file| File.new(file) }
end
查看__dir__
和Dir::chdir
的文档。