Delete a file
by Bruno · in Torque Game Builder · 08/31/2008 (3:44 am) · 7 replies
Hi,
Is there a way to delete a file from a script ?
After closing the file,
FR.Close();
I tried
FR.Delete();
Doens't do nothing, but does not give an error either.
thanks,
Bruno
Is there a way to delete a file from a script ?
After closing the file,
FR.Close();
I tried
FR.Delete();
Doens't do nothing, but does not give an error either.
thanks,
Bruno
About the author
#2
Doens't seem to do anything.,
I tried with the expandFileName and without it (i tought expandFileName was before Torque 1.7 ) ?
Any idea on what could be the problem ?
I can open, read or write to that same folder, so it's not a path problem.
thanks again,
Bruno
08/31/2008 (4:04 am)
Thanks Phillip,Doens't seem to do anything.,
I tried with the expandFileName and without it (i tought expandFileName was before Torque 1.7 ) ?
Any idea on what could be the problem ?
I can open, read or write to that same folder, so it's not a path problem.
thanks again,
Bruno
#3
Try and determine whether the TGB thinks the file exists or not.
You do need expandFileName unless you're refering to an absolute path, i.e. "C:\MyGames\..."
08/31/2008 (4:11 am)
Are you familiar with the file changes in 1.6+? tdn.garagegames.com/wiki/TGB/FileIOTry and determine whether the TGB thinks the file exists or not.
echo ("IsFile:" SPC isFile(expandFileName(...)));You do need expandFileName unless you're refering to an absolute path, i.e. "C:\MyGames\..."
#4
Let me show what i'm doing :
That code works fine.
IsFile is returning 1, so, it's working fine too.
Nothing happens there. The line runs fine, no errors, but no file is deleted.
08/31/2008 (4:19 am)
Yes, i'm familiar with the changes.Let me show what i'm doing :
%filename = "game/savegame/test.player"; %yes = FR.OpenForRead(%filename);
That code works fine.
echo ("IsFile:" SPC isFile(expandFileName(%filename)));IsFile is returning 1, so, it's working fine too.
fileDelete(expandFileName(%filename));
Nothing happens there. The line runs fine, no errors, but no file is deleted.
#5
This way, the file is deleted :
Torque, also reports that it can find the file, in both this situations :
However, it refuses to delete the damn file
filename is
%filename = "game/savegame/test.player";
why, oh whhyyyy ?
what am i doing wrong here... ?
08/31/2008 (5:53 am)
Well, made some more experiments, and i'm really confused.This way, the file is deleted :
fileDelete(expandFileName("C:\Documents and Settings\Bruno\Application Data\x\test\game\savegame\test.player"));Torque, also reports that it can find the file, in both this situations :
echo ("IsFile:" SPC isFile(expandFileName(%filename)));
echo ("IsFile2:" SPC isFile(%filename));However, it refuses to delete the damn file
fileDelete(expandFileName(%filename));
fileDelete(%filename);filename is
%filename = "game/savegame/test.player";
why, oh whhyyyy ?
what am i doing wrong here... ?
#6
It seems this is a known bug.
http://www.garagegames.com/mg/forums/result.thread.php?qt=74254
fileDelete doens't work in Torque..., great
08/31/2008 (7:23 am)
So,It seems this is a known bug.
http://www.garagegames.com/mg/forums/result.thread.php?qt=74254
fileDelete doens't work in Torque..., great
#7
08/31/2008 (12:45 pm)
It works every time that I used it! Are you sure it isn't deleting the file that resides in your AppData folder?
Associate Phillip O'Shea
Violent Tulip
I believe the function is:
fileDelete(expandFileName("game/myFile.ext"));