can we get a file from os in godot in runtime

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By iamkhan

I am making a project in which user is required to get files from os is there any way to get files

:bust_in_silhouette: Reply From: magicalogic

Yes using File class like this example from the docs.

func save(): 
        var file = File.new()
        file.open("user://save_game.dat", File.WRITE)
        file.store_string(content)
        file.close()

func load():
    var file = File.new()
    file.open("user://save_game.dat", File.READ)
    var content = file.get_as_text()
    file.close()
    return content

You may need to read about Data Paths here to see where the files are stored in the os here: https://docs.godotengine.org/en/3.3/tutorials/io/data_paths.html