How Do I Find Path of a File?

I’m trying to make a system that looks in a directory to find files of a certain type and load them onto a display. In my code, I had already found the files, but I want to do the reading and loading of the file in another method:

    void GetWorlds () {
        if (Directory.Exists(Application.DataPath + "\Worlds")) {
            string worldsFolder = Application.DataPath + "\Worlds";

            DirectoryInfo d = new DirectoryInfo(worldsFolder);
            foreach (var file in d.GetFiles("*.cubes"))
        } else {
            File.Create(Application.DataPath + "\Worlds");

I don’t quite know how to find the location of the file already specified to be able to send its information to the other method “DisplayWorldData”. Help please!

var directoryPath = Application.DataPath + “\Worlds”;
foreach (var file in d.GetFiles(“*.cubes”))
var path = file;
var fileName = path.Replace(directoryPath, string.Empty);

you can check references GetFiles here: