Game Development Community

filedelete path

by Bruno · in Torque Game Builder · 03/15/2011 (8:45 am) · 8 replies

Hello everyone,

I'm trying to use fileDelete to delete a player profile, but i'm having a problem with the path.

To save the profile, I'm using:

%fr = new FileObject("FR");
%yes = FR.OpenForWrite("game/savegame/player.sav");

and the file is saved on:
"C:/Documents and Settings/user/Application Data/CompanyName/GameName/game/savegame/player.sav"

However when i try to delete the file, using that same path:

fileDelete("game/savegame/player.sav");

It tries to delete that file in the working directory of the game (where the source, images, etc are located).
If I specify the full path:
fileDelete("C:/Documents and Settings/user/Application Data/CompanyName/GameName/game/savegame/player.sav"); the file is deleted, but I would need to know the windows username to specify the folder.

Does anyone know any workaround for this?
Any help would be appreciated.

Thanks,

#1
03/15/2011 (11:40 am)
Do you have a player.sav file in the working directory? Does it work if you remove that file and only have the one in the App Data directory?
#2
03/15/2011 (11:54 am)
No Chris, I have no player.sav on the working directory.

I did try copying player.sav to the working directory, just to see if it was deleted, and that's how I found out what was happening.

I only have the save files on the App Data directory.
#3
03/15/2011 (11:57 am)
Why are you deleting the file?

I've always used 1 file that stores everyone

numplayers
playerdata0
playerdata1
...
playerdataN-1

Then if there are no players my file would just contain a zero.
#4
03/16/2011 (5:54 am)
It's a QA request from a game portal, that user profiles should be deleted when profile is deleted.
#5
03/16/2011 (5:57 am)
The profile should be deleted when the profile is deleted... ?

Assuming you meant the file should be deleted when the profile is deleted.

If you store all of your profiles in 1 file then deleting a profile does not mean you have to delete a file as all profiles are stored in 1 file.

Which portal? That is the method I am using and my portal was perfectly fine with it. (Passed QA last week)
#6
03/16/2011 (6:06 am)
@Bruno - I think the reason why the portal requested this feature is because you are storing your player profiles in different files so when a profile is deleted the file should be deleted also.

If you are doing the way Chris is doing (which I would recommend you doing) I don't think you should have any problems with your portal.
#7
03/16/2011 (7:58 am)
Yeah that's what I meant (file should be deleted when profile is deleted).

Storing all profiles in one file, like you did, will do the thing - that way I won't need to delete it. That's a good solution, thanks :)

(it's for BigfishGames)
#8
03/16/2011 (8:15 am)
Perfect.

My game, which uses the same method, was just approved by BFG, so you shouldn't have any problems.