How are you formatting the hard drive without removing the files? Do you mean re-installing Windows on top of what you already have?
If you are trying to install Windows and want to keep your Apps, then choose "Upgrade" when installing it. If you are trying to re-isntall Windows 10, there is a Refresh PC option that will grab everything back.
But the main question that needs to be asking: why are you formatting your hard drive?