ruby - get files of certain extension from a directory (windows)
<p>I'm having trouble with the following piece of code where user input of directory name is used to fetch list of files of a particular extension on a <code>windows</code> machine</p>

<pre><code>puts "Enter the name of directory where files exist : "
directory = gets.chomp
csv_files = Dir.glob("#{directory}/*.csv")
</code></pre>

<p>Regardless of the directory input ( the directory has .csv files), the last line returns an empty array.</p>

<p>ruby version - <code>ruby 2.0.0p598 (2014-11-13) [i386-mingw32]</code></p>

<p><strong>Adding additional info asked in comments</strong></p>

<pre><code>PS C:\test&gt; irb
irb(main):001:0&gt; directory = gets.chomp
C:\test
=&gt; "C:\\test"
irb(main):002:0&gt; directory
=&gt; "C:\\test"
irb(main):003:0&gt; Dir.glob("#{directory}/*.csv")
=&gt; []

irb(main):004:0&gt; Dir.glob("#{directory}/*.*")
=&gt; []

irb(main):005:0&gt; Dir.glob("C:/" + directory + "/*.csv")
=&gt; []

irb(main):006:0&gt; Dir.glob("C:/test/*")
=&gt; ["C:/test/test_csv.csv"]

irb(main):007:0&gt; Dir.entries(directory)
=&gt; [".", "..","test_csv.csv"]

irb(main):010:0&gt; Dir.glob('./*.csv')
=&gt; ["./test_csv.csv"]
irb(main):011:0&gt;
</code></pre>