Godot Version
func populate_file_list():
# Ensure the list is empty before populating
clear()
# Open the user:// directory
var dir = DirAccess.open(“user://”)
if dir == null:
print(“Error: Failed to open directory.”)
return
print("Directory opened successfully.")
# Iterate through files in the directory
var file_name = dir.get_next()
print (file_name)
while file_name != "":
# Check if it's not a directory and ends with ".txt"
if !dir.file_exists(file_name) and file_name.ends_with(".txt"):
print("Adding file: ", file_name)
add_item(file_name) # Add file name to the ItemList
file_name = dir.get_next()
Question
I have my .txt files saved under user:// but my code just cant find anything under user:// what am I doing wrong???