Have you ever gone to open a program and an error popped up, saying the program cannot run due to a file that was corrupted? It’s a frustrating situation, especially when you need to use that program for work or a project. Usually it’s quite difficult to get that corrupted file back and in its proper location, although there’s some ways where you can get it back in a few short steps.

Follow along below, and we’ll show you why files get corrupted, how to retrieve a corrupted file and how to prevent files from getting corrupted in the future.

Why do files get corrupted?

Files can get corrupted for a number of reasons. One of the more common reasons is due to malware or a virus on your computer. Malicious software can find itself on your computer, infecting and ruining files that are important for a program (or even your system) to run. Even after removing malware off of the system, it, most of the time, doesn’t un-corrupt a file and return it to its normal state. It gets rid of the problem–the infection–but doesn’t necessarily restore the corrupted file the infection lost or got rid of.

Corrupted files can happen when there’s an error during the process of writing a file to the hard disk. For example, if you’re saving, say, a 3D model you’ve been working on to the disk, but the program gives you an error or experiences a glitch during that process, that file of the 3D model could become corrupted and unable to open.

Sometimes the program will shoot out an error message and allow you to retry the save, but other times, you’ll never even realize until you go to try and open that file again, and it gives you an error saying it’s corrupted.

If you have a mechanical hard drive, corrupted files can randomly pop up due to the hardware failing (i.e. a bad sector or sectors going bad). If not replaced soon, more files will begin to become corrupted and you could end up losing a lot of data. This is why it’s always good to have a solid backup strategy in place.

Finally, files can become corrupted by your system not being shut down properly. For instance, if there is an outage and your computer is shut off unexpectedly, any changes that were being made to files could lead to those files becoming corrupt. Usually, when you shut down your PC, it closes and saves everything safely so this doesn’t happen. Abrupt shut offs prevent that safety feature from completing.

Getting back your corrupted files

Unfortunately, there’s not a whole lot of options available for fixing corrupted files that you created (i.e. word documents, 3D models, etc). However, replacing files that are system and program specific are quite easy to fix.

One thing you can do is as simple as downloading those specific files from the Internet and putting them back in their proper location. You can usually grab the file name from the error that pops up when you try to open the affected program or section of the system, and it’ll usually show you a file path, too. This makes it quite easy to snag the file from the Internet and put it in its proper place.

Windows 10 System File Checker

If you’re having a problem with system files specifically, Windows makes it super easy to check the integrity of those files. To check for any problems (and automatically fix problems) we have to run the System File Checker tool by way of Command Prompt.

Open Command Prompt. You can access this easily by clicking on the Start menu and simply searching for “cmd.” This operation will also work in Windows PowerShell.

Once either program is open, type in the command DISM.exe /Online /Cleanup-image /Restorehealth. Note the spaces before the slashes; make sure to keep those in the command, otherwise it won’t work properly. Once you press “Enter,” it can take a little bit for the operation to complete. If the command doesn’t work, you may need to open Command Prompt as an administrator.

When you run this command, DISM (which is the System File Checker program in Windows, called Deployment Image Servicing and Management. It basically runs through all of your system files and verifies the integrity of them all, or, in other words, that they’re working properly) will run through Windows Update to retrieve new files that will replace your corrupted system files, which is why this process can take some time.

That command works for most system files, but not protected system files. To run a scan on protected system files, type in the command sfc /scannow. This will replace your corrupted protected system files with a cached copy located elsewhere on your PC.

Once the commands run through their operations, you should be done. You should get a message that tells you the repair was successful, or that Windows wasn’t able to find any integrity violations (which is a good thing!).

Video Games

Video games can usually be fixed easier than other programs. Most games are now delivered through digital platforms, such as Steam. They make it easy to fix corrupted installs. You simply select the game your having issues with and press a neat little button under the games’ Steam property settings called Verify Integrity of Game Cache. It’ll grab and replace any files that you’re having issues with. Even then, many games that don’t run off of a digital platform usually have a built-in “Repair Files” button that can easily be used without having to reinstall the entire game.

Documents

Sometimes you can save documents that are corrupt, especially in Microsoft Word, which uses a feature called Open and Repair. Often, Microsoft Word does this automatically when you open a document, but if you find that you need to do it manually, it’s quite easy. In Microsoft Word, under the File tab, click on Open. Navigate to the file you want to open, select it, click the arrow on the Open button, and select Open and Repair. This should repair and open any corrupted document files you have. Many other Office programs, like Excel as an example, offer similar built-in tools to help with file corruption problems.

Other files

Like we mentioned earlier, there’s not too much else we can do for files that you created, unless the program you used to create a file has its own built-in Open and Repair function. For example, with a 3D modeling program like Autodesk 3DS Max, there’s not too many “repair” specific functions built-in, but the program does create backups of your scenes automatically in a separate folder.

So, look out for any specific functions that your programs may have to repair files or even backup files, as you might be able to save them/get them back. Just do keep in mind that getting back user-created corrupted files is difficult and often not possible. This is why we recommend having a good backup strategy in place, as it can save a lot of heartache if any file loss were to happen.

Recovering Files in Linux

In Ubuntu Linux, there are a handful of programs that can help you fix corrupted files. One of those programs that you can get in Ubuntu is TeskDisk. It’s free and open source, used primarily for recovering partition tables that may have been deleted accidentally or even partitions that are compromised due to a virus or human error.

What everyday users might use more commonly is Photorec, another open source tool. It’s great at image recovery, but also does astoundingly well at recovering documents, lost files, archives from hard disks and CDs. It works so well because it ignores the file system and goes straight for the “underlying data,” so you’ll still be able to recover files even if the integrity of your media system has been severely compromised. You can find detailed instructions for using PhotoRec here.

Closing

And that’s all there is to it! File loss can be devastating, especially if you’re dealing with user-created files, since they’re much more difficult to fix if they get corrupted. Luckily, there’s still some thing you can do, and if you ever have problems with system files, those are at least easily fixable, if you follow the steps outlined above. And to reiterate, it’s always good to have a backup plan in place, as you never know when a virus or human error can compromise some of your most important files. Having a backup plan in place means that you can always retrieve clean versions of your files after getting rid of the problem that caused it in the first place (i.e. malware).

Have any tips that you’ve used for fixing corrupted files? Be sure to leave a comment in the comments section below. We’d love to hear from you. And if you need extra help, be sure to visit the PCMech Forums for technical assistance.