Problems with built-in file IO tutorial
by Joaquin Maguire · in Torque Game Builder · 03/25/2010 (3:51 pm) · 4 replies
Looking at the file IO tutorial in the built-in Torque docs, I copied this method:
I then run my game, open the console and type writeFile(). The console echoes "File Written," so presumably the program thinks everything is fine. However, nothing is written, even when I add a file for it to write to. It seems like this should be fairly straightforward, what am I missing?
function writeFile()
{
%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();
}I then run my game, open the console and type writeFile(). The console echoes "File Written," so presumably the program thinks everything is fine. However, nothing is written, even when I add a file for it to write to. It seems like this should be fairly straightforward, what am I missing?
Associate William Lee Sims
Machine Code Games
This will take you to your Application Data directory. If you sort by the date, you'll probably find the directory it added your file to in the most recently added directory. In a default project, that will be "Independent/UntitledGame".