Hi guys. I'm running windows seven.

text2.txt is located in O:\Ruby

The program io.rb is located in O:\Ruby\Practice

io.rb contains the following code:

f = File.new("O:\Ruby\text2.txt", "r")
catch(:end_of_file) do
  loop do
    puts f.gets
    throw :end_of_file if f.eof?
  end
end
f.close

I run it in SciTE, got the following error:

>ruby "io.rb"
io.rb:19:in `initialize': Invalid argument - O:Ruby  ext2.txt
(Errno::EINVAL)
  from io.rb:19:in `new'
  from io.rb:19:in `<main>'

>Exit code: 1

I fail to see anything wrong with the code.  Can anyone help please?

If both io.rb and text2.txt are in O:\Ruby\Practice, and I change the
first line of code into:    f = File.new("text2.txt", "r")  ,
it works fine.

But I want to know why the full path isn't working if text2.txt is in a
different directory.

Thanks guys!!!!

-- 
Posted via http://www.ruby-forum.com/.