Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Ruby 中,如何使用通配符检查文件是否存在?
显然这似乎不起作用:
File.exists?("/folderOfFile/Filename*.ext")
您的通配符将引用一组文件,而不是单个文件。你可以用Dir::glob这个:
Dir::glob
!Dir.glob('/folderOfFile/Filename*.ext').empty?