title: Ruby: Dir.chdir using data from a text file in windows
body: <p>I am trying to use a script to change the working directory using Dir.chdir</p>
  
  <p>This works:</p>
  
  <pre><code>dirs = ['//servername/share','//servername2/share']
  
  dirs.each do |dir|
    Dir.chdir dir
  end
  </code></pre>
  
  <p>If I put the above share information into a text file (each share on a new line) and try to load:</p>
  
  <pre><code>File.foreach("shares.txt") {|dir|
    Dir.chdir dir
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>'chdir': No such file or directory - //servername/share (Errno::ENOENT)</p>
  </blockquote>
  
  <p>How can I read the shares from a text file and change to that directory? Is there a better way to do this?</p>