saving to persistentdatapath not working

    public class SaveScore : MonoBehaviour
    {
        public string saveName = "SavedScore";
        public HighScore highScore;
       
        public void SavetoFile()
        {
            string path = Application.persistentDataPath;
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream saveFile = File.Create(path + "/" + saveName + ".bin");
            formatter.Serialize(saveFile, highScore);
            saveFile.Close();
            Debug.Log("File Saved");
        }
    }

This method is triggered upon your lives becoming zero. the same routine that calls this method calls async to load the menu scene, on awake of the menu the loading method is called. In my console it’ll print out the Debug shown above but when i go to that directory, no such folder is created and the loading method says the directory made by the save doesn’t exist. Does anyone know what I did wrong here?

Do not use BinaryFormatter, it will make your application vulnerable during deserialization.
See Microsoft’s own documentation here.

Use BinaryReader and BinaryWriter instead (see examples how to use them).