Keep in mind that this guide is for the 'main' Pokémon save type, regardless if it's played on emulator or imported using save manager.
This applies to both 3DS and Switch.
In the images below, Citra was used simply as a convenient way to show screenshots, do not be misled by it!
Scenario 1: (can be retail or emulator, I'm just using Citra as an example)
You load the game and it tells you it's corrupted, however PKHeX is able to load the save.
What you should do:
1. Check the folder you import the save from. Your file in the folder MUST be named main
(Look at the screenshot of the file folder above. Notice how my file is called main1? That's the mistake: it was incorrectly named.)
2. The files in the folder has to be exact.
For 3DS: main MUST be the only file in that folder.
For Switch: main MUST be in that folder. backup and poke_trade can be there, but isn't necessary.
There cannot be other files in the same folder you import from, such as main.bak etc.
3. (Citra only) Also do not rename the folders that contain the main. The wonky numbers generated by Citra are the correct folder names. Changing them will screw it up.
Game says save is corrupted, and PKHeX is unable to load the save.
Chances are, your dumped save file is indeed corrupted.
Maybe there was an error with dumping the save -> redump the save, provided that you’re able to continue the game and it launches on your console.
Perhaps there was an error when transferring save to PC via FTP -> if you were using FileZilla, change the setting to use binary transfer mode instead of ascii.
If the steps above were not able to resolve the problem, load up an older copy of your save. Also make sure you're using latest version of PKHeX.
Oh, ALWAYS keep a safe backup of your save in a completely differently folder, especially before any edits or transfers etc, so that if any corruptions occur, you always have a backup to revert to.
Note: IF you played on Citra, and used the Emulation > Save state (example below)
You need to properly save the game, using the in-game menu.
Open this spoiler for steps.
Note - If the FTP transfer process indeed screwed up your save:
For 3DS - Try using this.
For Switch - There's no solution. The save is dead.
The Switch encrypts the save, so missing a byte is fatal.
Instances of people mucking up Notable case studies:
Filezilla needing Binary Transfer Mode instead
Game displays save as corrupted, cause it wasn't named correctly
PKHeX won't read the save, as it is empty
Changing names of Citra Folders messed up the save recognition
User using emulation > save state