FileTest::exists? Not Finding Windows Files with Spaces in Name

Dennis Mendelson wrote:

Should have mentioned that I have tried using double-quotes in the
following ways:

"C:\Documents and Settings\test.txt"; and

puts "C:\Documents and Settings\test.txt"

C:Documents and Settings est.txt
=> nil

Notice something? You need double backslashes in double quotes.
Alternatively use single quotes

puts 'C:\Documents and Settings\test.txt'

C:\Documents and Settings\test.txt
=> nil

C:\"Documents and Settings"\test.txt, both of which Windows
recognises.

This is incorrect Ruby syntax:

C:\"Documents and Settings"\test.txt

SyntaxError: compile error
(irb):2: syntax error
C:\"Documents and Settings"\test.txt
   ^
(irb):2: syntax error
C:\"Documents and Settings"\test.txt
                            ^
        from (irb):2

Note, ruby != bash

Kind regards

    robert

mercifully. :wink:

-a

···

On Tue, 3 May 2005, Robert Klemme wrote:

Note, ruby != bash

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
renunciation is not getting rid of the things of this world, but accepting
that they pass away. --aitken roshi

===============================================================================

Or just you forward slashes, the Ruby standard.

···

On Tuesday 03 May 2005 09:44 am, Robert Klemme wrote:

Dennis Mendelson wrote:
> Should have mentioned that I have tried using double-quotes in the
> following ways:
>
> "C:\Documents and Settings\test.txt"; and
>
>> puts "C:\Documents and Settings\test.txt"

C:Documents and Settings est.txt
=> nil

Notice something? You need double backslashes in double quotes.
Alternatively use single quotes