Read directory in build version

Hi,

I want to get all files from directory, but in production the folder does not appear.

private static readonly string themePath = Application.dataPath + "/data/";

    public static void ReadFiles()
    {
        if (dataRead) return;
        DirectoryInfo dir = new(themePath);
        FileInfo[] info = dir.GetFiles("*.xml");
        foreach (FileInfo f in info)
        {
            XmlDocument doc = new();
            doc.Load(f.FullName);

            XmlElement root = doc.DocumentElement;
            string name = root.SelectSingleNode("/theme-data/name").InnerText;
            Color32 background = HexToColor(root.SelectSingleNode("/theme-data/background-color").InnerText);
            Dictionary<Regex, Color32> highlight = new();
            foreach (XmlNode node in root.SelectSingleNode("/theme-data/highlights").ChildNodes)
            {
                Regex regex = new(node.ChildNodes[0].InnerText);
                Color32 color = HexToColor(node.ChildNodes[1].InnerText);

                highlight.Add(regex, color);
            }

            themes.Add(new Theme(name, highlight, background));
            themeNames.Add(name);
        }
        dataRead = true;
        if (PlayerPrefs.HasKey("editorTheme"))
            currentTheme = GetThemeByName(PlayerPrefs.GetString("editorTheme"));
        else
            currentTheme = GetThemeByName("Default");
    }

What can I do to make that folder appear, or somehow fix the issue?

You cannot use anything from the System.IO namespace to read assets from a build.

Here are three alternatives:

You may use Resources.Load() or Resources.LoadAll() (simplest)

You may use Addressables or Asset Bundles (most-powerful)

You may stream non-Unity assets ONLY out of the StreamingAssets mechanism.

Thanks, that helps