Game Development Community

File is not open for writing

by University of Gotland (#0009) · in Torque Game Engine · 12/18/2007 (8:15 am) · 1 replies

Hello!
I'm using TGB 1.5.1 and seems have an issue with this new version.

This is the code to write to a file:

%file = new fileObject();
if(%file.openForWrite(".~/data/files/test.txt"))
{
%file.writeLine("Hello World!");
echo("File Written");
}
else
{
error("File is not open for writing");
}
%file.close();
%file.delete();

It works for those using an old torque but with 1.5.1 it doesn't seem to work.
The file test.txt is located in mygamefolder/game/data/files/
But still it says File is not open for writing.

Me and my mates have been working on this for several hours now and the only conclusion we came to is that this code doesn't work for TGB 1.5.1. The new version must be the only reason.

So have anyone managed to write to a file in this version!? Please show me a code example from it then.
I really need to get this problem solved. Working with an project here..

#1
12/18/2007 (8:26 am)
There were problems with File IO in 1.5. These have been fixed in 1.6, which is available for download from your account.