• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows [Solved!] Can't find .txt file after opening and writing to it

FacesOfMu

Member
Hi all, I'm having what seems to be a pretty basic problem. I'm trying to open a text file for appending to, and despite file_exists reporting it has been created, I can't find it anywhere:

GML:
global.logfile = working_directory + "log " + string(date_current_datetime()) + ".txt"
show_debug_message(global.logfile)
show_debug_message("File exists 0: " + string(file_exists(global.logfile)))
logf = file_text_open_append(global.logfile)
show_debug_message("File exists 1: " + string(file_exists(global.logfile)))
file_text_write_string(logf, "meta_debug Create")
show_debug_message("File exists 2: " + string(file_exists(global.logfile)))
file_text_close(logf)
show_debug_message("File exists 3: " + string(file_exists(global.logfile)))
show_debug_message("Filename path: " + string(filename_path(global.logfile)))
I'm on Windows 10. I've checked the C:\Users\TehManticore\AppData\Local\GameMakerStudio2\GMS2TEMP folders and C:\Users\TehManticore\Documents\GameMakerStudio2\ folders(edited)
I've even copy and pasted the example code at https://docs.yoyogames.com/source/d...le handling/files/file_text_write_string.html and still no text file

Output:
Code:
Y:\Game1_6228D944_VM\log 44171.75.txt
File exists 0: 1
File exists 1: 1
File exists 2: 1
File exists 3: 1
Filename path: Y:\Game1_6228D944_VM\
What's weird is that is says "file exists 0: 1" which is before I've even opened the file
 

Evanski

Raccoon Lord
Forum Staff
Moderator
Your code during runtime writes a file to C:\Users\TehManticore\AppData\Local\(Your project name)
but game maker being sandboxed will check in the simulated drives (mostly Y: ) for the file

your code will work as you expected in the executable, but running from the ide will result in this issue, to fix this for the time being
check for the file in C:\Users\TehManticore\AppData\Local\(Your project name) rather then working_directory

you dont need to fix writing, you just need to fix reading
 

FacesOfMu

Member
your code will work as you expected in the executable, but running from the ide will result in this issue, to fix this for the time being
check for the file in C:\Users\TehManticore\AppData\Local\(Your project name) rather then working_directory
Yes, I've checked C:\Users\TehManticore\AppData\Local\GameMakerStudio2\ and it's not there or in any sub folder
 

FacesOfMu

Member
Wait, it was in C:\Users\TehManticore\AppData\Local\(project name) (the folder ABOVE it) like you said! I don't know why it wasn't in the Gamemaker Studio 2 folder.
Thanks!
 
Last edited:
Top