ASKED AND SOLVED BY ME: open("file.txt", 'r') in bge??? "No such file or directory"?

:spin:I’m trying to update and old script. I’m trying to open() a file for the engine to read. Would anyone be so kind as to tell me how I need to write it down?

I wrote it every which way possible, it keeps saying there’s no such file or directory.

I fixed it??? for the r function to work, I had to set the file name as name thing like this

file = “file.txt”
open(file, ‘r’)

It works now but for the ‘w’ part it accepts
open(“file.txt”,‘w’)

Can someone tell me why, please?

No need to write you solved the thread subject by yourself, just go to your thread top > Thread Tools > Mark as Solved; the thread will automatically put [SOLVED] at your thread title.