Why not serialize to JSON and write as text, then you can read the text and deserialize it to an object.
UPDATE
Simple example...
sample class to be stored and retrieved:
public class Theme
{
public string ForeColor { get; set; }
public string BackColor { get; set; }
}
1. serializing to JSON, saving to file
Theme myTheme = new() { ForeColor = "red", BackColor = "white" };
string rawJson = System.Text.Json.JsonSerializer.Serialize(myTheme);
File.WriteAllText("Theme.json", rawJson);
2. loading from file, and then deserializing:
string readRawJson = File.ReadAllText("Theme.json");
Theme readMyTheme = System.Text.Json.JsonSerializer.Deserialize<Theme>(readRawJson);