Game Development Community

Problem with file IO

by Selin · in Torque Game Builder · 03/15/2011 (10:23 pm) · 3 replies

I had a problem with file IO while save the data. This code is from internet. I can't get the test.txt file in my directory as the console there is already written file written. Can anyone tell me what the problem occur?

funtion writeFile()
{
%file = new FileObject();

if(%file.openForWrite("./game/data/test.txt"))
{
%file.writeLine("Hello World!");
echo("File Written");
}

else
{
error("File in not open for writing");
}

%file.close();
%file.delete();
}

#1
03/16/2011 (5:13 am)
You just posted to a thread that had the exact same question (and the exact same code). The question was answered in that post.
#2
03/16/2011 (7:49 am)
Change:

%file.openForWrite("./game/data/test.txt")

To this:

%file.openForWrite("game/data/test.txt")
#3
03/16/2011 (8:23 pm)
The file is save in Application directory. got any solution to change the path of the file?