Fortunately, if you try to fold an unfoldable line, nothing happens (at least in my experiments). As far as I know, no data can be lost from improper folding (View > Unfold All should always show everything again). And I did try to make it clear that “if [the] original file changes between the save and the load, the state is unpredictable.”
In case I wasn’t clear enough:
warning / disclaimer@Sal-Ricciardi, the PythonScript solution shown is only a hack for solving a very limited subset of the problem, as a proof of concept – specifically, re-applying the same fold levels to the exact same state of a particular file. You are responsible for keeping proper backups of important data. You are responsible for ensuring you load the correct fold-save file for a given file. You are responsible for making sure that the file doesn’t change between loads.
If you would like more features, you may feel free to develop the above script into a more feature-rich version of the PythonScript, or use the PythonScript shown as a basis for a full-fledged plugin.
I make no guarantees or warranties. But I do hope this helps you.