Check if file exist directory troubles

Status
Not open for further replies.

GigaTurtle

Warper
Member
Joined
May 11, 2018
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMXP
A friend and I are working on our own games and would like to add bonus content to our games if the player has save data of the other game on their computer. but the "user name" folder seems to be an issues while checking for a save file.

FileTest.exist?("C:\\users\*name*\Saved Games\Game\Game.rxdata")

Can anyone help me with this?

Edit:
While trying to find an answer for this I found a function called "dir.children()" or "dir.each_child()" which checks each entry for that directory. So I think I need to change the directory with Dir.chdir("C:\\users") then follow up with Dir.each_child("Saved Games\") and finally check for the actual file. FileTest.exist?("Game\Game.rxdata")

It is going to be a little bit before I can test this, if anyone figures this out please let me know.


Edit2: Still try to work this out, but the script has changed a little.
FileTest.exist?("C:\\users/"+"*name*"+"Saved Games/Name_of_Game/Game.rxdata")


Final Edit:
I have figured it out, apparently I was looking for an "environment" which is the root directory of a user account, for anyone using Windows 7 or newer this should be what you are looking for if you which to do the same.

if FileTest.exist?("#{ENV['HOMEPATH']}\\Saved Games/NameOfGameHere/Game.rxdata") == true
(do a thing here)
else
(don't do a thing or do a different thing)
end
 
Last edited:

GigaTurtle

Warper
Member
Joined
May 11, 2018
Messages
4
Reaction score
0
First Language
English
Primarily Uses
RMXP
The problem has been solved, this thread can now be closed.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,842
Reaction score
5,223
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:

Forum statistics

Threads
105,855
Messages
1,017,007
Members
137,563
Latest member
MinyakaAeon
Top