Search code examples
rubywindowsunc

How do I address a UNC path in Ruby on Windows?


I'm trying to access a UNC share via irb on Windows. In the Windows shell it would be

\\server\share

I tried escaping all of the backslashes.

irb(main):016:0> Dir.entries '\\\\server\share'
Errno::ENOENT: No such file or directory - \\server\share

and using the IP address instead of the name

irb(main):017:0> Dir.entries '\\\\192.168.10.1\share'
Errno::ENOENT: No such file or directory - \\192.168.10.1\share

Solution

  • Try to escape '\' with another '\'

    Dir.entries('\\\\\\\\192.168.10.1\\\\share')