FileAccess.GetFileAsString mangling path parameter (c#)
Asked Answered
F

1

0

Hi all,

I'm having a little trouble with loading the information from a text file using FileAccess.GetFileAsString - I'm using a res:// path and DirAccess.GetFilesAt to get a list of files in a path, and then process them. The problem I'm having is that whilst GetFilesAt does return a proper list of files in that path, passing a concatenated path to GetFileAsString is throwing "The Filename, directory name or volume name syntax is incorrect".

The path it's returning in the error message is a strange mashup of what I'm actually passing - for example, the search path passed to GetFilesAt is "res://WorldData/Factions", and concatenating one of the results gives "res://WorldData/Factions/Madeupistan.faction". The error message I get back complains about a path that gives the absolute OS path to the project, and strips the file extension: "c:\Users\Spugnut\repos\Project\Madeupistan".

I know that the whole use case is probably better handled using the inbuilt resource system; but the project stakeholders would like to keep the backend code portable, as Godot is only being trialled at present.

I have that grim feeling I've missed something obvious, and am really hoping that's the case - any guidance gratefully recieved.

Many thanks!

Formation answered 13/3 at 12:15 Comment(0)
F
0

Formation Figured it out, turns out I'd got an overload mixed up for one of the glue methods - thanks anyway 🙂

Formation answered 13/3 at 20:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.