It seems this has been an issue for quite some time:
http://forums.codeblocks.org/index.php?topic=18286.0This is still happening, 5 years later. If you go into the code folding settings under Settings->Editor->Folding and enable "Fold all on file open" (be sure to enable folding itself at the top as well) and then open a source file it always "Toggles All Folds" instead of actually performing a "Fold All".
Case in point: open a source file, go Edit->Folding->Fold All. See it all folded nice and neat, then close it and re-open it. Now it's all unfolded. Close it and open it again and everything will be folded again!
Worse yet: unfold something, leaving everything else folded and close it. Re-open it and now what you unfolded will be folded while everything else that was already folded will be unfolded again. The "Fold All on Open" actually performs a Edit->Folding->Toggle All, which is the equivalent of pressing Shift+F12 instead of performing an Edit->Folding->Fold All, which is what the name of the option under the editor settings would suggest it's supposed to actually do - and would be vastly more useful than flip-flopping the folding state of everything each time you open a file.
Even if I disable "Fold All on Open" it doesn't even retain the folding state of everything properly, at all. It's constantly folding and unfolding random stuff until it 'settles' on a specific folding configuration when it finally stops toggling random things from being folded. Just having folding enables automatically entails having to deal with random stuff being folded and unfolded all the time - and having "Toggle All" as the only folding-related hotkey is totally useless in this situation.
It would be nice if there was a keyboard shortcut for Fold All because it would be WAY more useful than a "Toggle All" hotkey that just toggles everything - which is pretty useless with the bugs that are in play - but I'll settle for the issue above being fixed as it would make CodeBlocks darn well near perfect as an editor IMO.