Hey!
Im trying to make a func, where when you press a button, it searches, are there any files there and then prints them(each's name).. but it doesnt work!
Here's the code..
func _on_Hide_pressed():
var dir = Directory.new()
if dir.open("res://SAVES_folder") == true:
dir.list_dir_begin()
var files = dir.get_next()
while(files != ""):
if dir.current_is_dir():
print(files)
else:
files = dir.get_next()
else:
print("error")
When i press the Hide button, it prints the "error" statement of my code. Whats is wrong here? I followed the example that is in Godot code it self...
"""""""""
func dir_contents(path):
var dir = Directory.new()
if dir.open(path) == OK:
dir.listdirbegin()
var filename = dir.getnext()
while (file_name != ""):
if dir.currentisdir():
print("Found directory: " + file_name)
else:
print("Found file: " + file_name)
filename = dir.getnext()
else:
print("An error occurred when trying to access the path.")
"""""""