File.open(“test.txt”) or File.open(?) created once an accessibel file.
After deleting teh file the same command provided me with:
Error: #<Errno::ENOENT: No such file or directory @ rb_sysopen - test.txt>
Deleting temp files and repairing the SU exe did not make File.new work.
What to do?
The File.open or .new command is entered and executed via the Ruby console.
In case I create a file with the same, or another name directly via windows I am able to write and change the file by File.open() in the console. The path to the file is found and the file gets changed.
Just creating the file from the console or an .rb is not possible.
To expand on @dezmo’s reply, in Ruby and many other coding languages the backslash character \ is an escape which gives the next character in a string special handling. For example \t denotes a tab character. Such languages use the forward slash as the path separator. Use of backslash in file paths on Windows was an ill-advised choice made way back in the MSDOS days, probably just to be different.
You can avoid the problem by doubling the backslash, but that’s a nuisance!
file = File.new(“c:/Users/xxx/Desktop/logtst.txt”, “w”);file.puts(“something”);file.close
Did work!!! thnks
thought I tried it from the beginning. Apparntly not!
You are likely right about the mode. But by the time the snippet got down to where I looked, it was in double quotes and I didn’t backtrack to notice the original single quotes.
Also it is not the user using the wrong quote characters, it’s the forum software that is replacing them with “smart quotes”. The poster can overcome this by delimiting code snippets with backquote characters. Ie … "smart quotes".
Putting the first line of that post between backquote characters, the forum does not convert the wrong character of single quotes to the right one: File.new(‘C:\Users\xxx\desktop\logtst.txt’)
However the “error” is much more visible,
I guess the poster using the wrong editor for coding…