0 votes

There is a code and a file that exists and lies in the same directory as the file.cs

    var FileTextDebug = new Godot.File();

    FileTextDebug.Open("names.txt", File.ModeFlags.Read);
    FileTextDebug.Close();
    GD.Print("Debug:" + FileTextDebug);

Instead of the text what's inside names.txt, outputs this:

Debug:[_File:1480]

What ideas does anyone have?

Ready-made code after the response, maybe someone will need it:

    var FileTextDebug = new Godot.File();

    FileTextDebug.Open("names.txt", File.ModeFlags.Read);
    string DeugText = FileTextDebug.GetAsText();
    FileTextDebug.Close();
    GD.Print("Debug:" + DeugText);

Thanks for the answer: exuin

Godot version 3.2.3 Stable
in Engine by (148 points)
edited by

1 Answer

+1 vote
Best answer

You probably want the File.get_as_text() method.

by (7,190 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.