文件(File)损坏是对文件中数据的一种意外或意外损坏。文件(File)损坏有多种形式,并且由于各种原因而发生,但结果是相同的:您无法读取数据。
在某些情况下,您可以逆转或修复文件损坏,但这并不总是可行的。最好了解为什么会发生腐败以及如何防范腐败。
文件损坏(Files)意味着(Mean)什么?
“文件”是应作为一个单元读取的相关数据的集合,以特定的文件格式编写。例如,Microsoft Office Word文件中的所有数据都与您创建并以.docx文件格式存储的Word文档相关。(Word)如果一半文件突然无法读取,您可能无法打开您的文档。即使可以,也会丢失很多信息。同样(Likewise),缺少或更改随机值的Excel电子表格将毫无价值。
任何计算机文件都由二进制代码组成。它是一串 1 和 0 组成的位组,代表诸如字母之类的数据。
在ASCII码中,字母“A”用二进制码01000001表示。如果我们把一个位,比如最后一个1改成0,那么“A”就变成了一个“@”!
这就是腐败在基本层面上的运作方式。文件中的位值被更改或擦除,导致文件不可读或仅部分可读。
如何判断是否发生文件损坏(File Corruption Has)
文件损坏可能有各种症状,具体取决于哪些文件已损坏以及它们的重要性。
CRC 错误(CRC Errors)
循环冗余校验(Redundancy Check)( CRC ) 检查文件是否完整且存储正确。CRC(CRCs)将公式应用于原始原始文件中的数据,从而生成一个数字作为输出。如果您对该文件的任何副本应用相同的公式,则该数字应该相同。如果数字不同,则您正在处理损坏或更改的文件。
当您尝试从损坏的光盘或快死的硬盘驱动器复制数据时,您最常看到此错误,但许多应用程序在根据正确值表自检文件时可能会出现CRC错误。(CRC)
文件打开错误(File Opening Errors)
如果文件已损坏,它要么无法打开,要么会以乱码的结果打开。某些文件类型是流式传输的,并且在某种程度上可以容忍损坏。例如,如果您的视频文件有一些损坏,媒体播放器应用程序可能会显示图片中断或卡顿,否则,播放整个文件。
其他类型的文件,例如程序可执行文件,必须 100% 完整,否则程序将无法启动。
其他文件类型(例如您创建的文档)可能会打开但缺少重要信息,例如文档中的实际值或格式。
奇怪的行为和故障(Strange Behaviors and Glitches)
当应用程序需要的资源或设置文件损坏时,它们可能会更巧妙地显示出来。程序不一定无法启动,但一些依赖这些文件的子组件可能会出错、什么都不做,或者使整个应用程序崩溃。
系统崩溃和不稳定(System Crashes and Instability)
当您收到损坏的系统文件时,它会从根本上影响您的计算机。您可能会突然出现看似随机的BSOD(BSODs)(蓝屏(Blue Screen)死机(Death))计算机崩溃,或者系统挂起或无法按预期方式工作。这种类型的严重(Critical)文件损坏是最具破坏性的,并且在许多情况下通常可能表明您的硬件存在严重问题。
为什么会发生文件损坏?
现在我们知道什么是腐败,但它是如何发生的呢?
虽然腐败只是比特值的混乱和破坏性的改变,但这些改变值的原因有很大的不同。这主要是因为计算机媒体有许多不同的形式,并且以非常不同的方式存储二进制数字。
突然断电(Sudden Power Loss)
存储设备遇到文件损坏的最常见原因之一是突然断电。对于机械硬盘驱动器尤其如此,在写入磁盘时切断电源可能会清除数据。过去,磁盘的读/写磁头在断电时可能会撞到盘片上,但现代驱动器即使突然断电,仍然可以安全地“停放”磁头。
这并不意味着机械或固态驱动器不会因数据丢失而损坏。如果断电时驱动器正在主动写入数据,则可能只有部分文件已进入磁盘。两种类型的驱动器都使用易失性高速缓存。这意味着如果断电,它们里面的数据就会丢失。
硬件故障(Hardware Failure)
所有存储介质的寿命都是有限的。它们可能会磨损或开始出现故障。有时,这种失败会随着时间的推移慢慢发生,有时,它是突然的。任何处理过机械硬盘的人都知道许多驱动器在不久后死机之前会发出可怕的“死机”。
不仅仅是硬盘驱动器。错误的 RAM(Faulty RAM)可能会导致数据损坏,因为错误的值被写入磁盘,划伤的光盘可能由于物理损坏而无法读取,等等。
恶意软件(Malware)
恶意软件(Malware)包括任何蓄意恶意编写的软件。恶意软件感染导致的数据(Data)损坏或破坏可能是故意的,也可能是偶然的。在大多数情况下,恶意软件(Malware)作者没有太多的动机来破坏您的数据。相反,他们会为了金钱(勒索软件)而将其作为人质,或者将其窃取以在黑市上出售。
在某些情况下,编写恶意软件只是为了播下混乱和破坏。旨在破坏或破坏数据的恶意软件通常以几乎无法恢复的方式这样做。(Malware)
防止和扭转文件(File)损坏
最好从一开始就防止腐败影响你,但在某些情况下也有办法扭转它。
检查磁盘是否有错误(Check Disks for Errors)
您可以使用各种Microsoft Windows和第三方实用程序来检查当前错误,例如驱动器上的坏扇区。您还可以使用实用程序来诊断驱动器的操作日志,以预测故障是否迫在眉睫,让您有时间将数据移至其他地方。
查看如何检查硬盘错误(How to Check Your Hard Drive for Errors)以获取详细说明。
进行频繁备份(Make Frequent Backups)
“备份(Backing)”数据描述了各种各样的做法。其中包括克隆整个驱动器以防万一出现故障、创建ZIP文件存档、将特定文件备份到云、自动对外部驱动器进行增量备份等等。如果您有最近的数据备份,那么损坏将成为烦恼而不是灾难。
如果您想了解有关备份的更多信息,我们有几个有价值的指南:
这些应该可以让您在现代Windows系统上进行备份,但 macOS 用户可以查看我们的Time Machine 指南(Time Machine guide)。
作为一项额外的预防措施,您还可以手动创建系统还原点(manually create a System Restore point),以便在与硬件故障无关的破坏性文件更改之前回滚到Windows安装的先前版本。(Windows)
使用文件验证功能(Use File Verification Features)
一些软件客户端也可以运行文件验证操作。例如,Steam视频游戏客户端可以检查游戏文件是否被更改(check whether a game’s files have been altered),并从主在线副本恢复原始数据。
在卸下驱动器之前弹出驱动器(Eject Drives Before Removing Them)
无论磁盘类型或操作系统如何,都应在拔出驱动器之前将其弹出。至少,等到磁盘活动指示灯停止后再拔掉它,但理想情况下,花一两秒钟弹出闪存驱动器或外部硬盘。
使用防病毒软件(Use Antivirus Software)
如果您不想与恶意软件相关的损坏,请使用防病毒软件。Windows、macOS和Linux有多种选择。
使用系统文件检查器 (SFC)(Use the System File Checker (SFC))
在某些情况下,您可以确定您的文件是否发生损坏并(and )自动修复它们。Windows有几个文件修复工具来修复损坏的Windows系统文件,例如系统文件检查器(System File Checker)。您可以在我们的使用命令提示符命令修复或修复损坏文件(Using the Command Prompt Commands to Fix or Repair Corrupt Files)的指南中获得确切的详细信息,该指南还涵盖了DISM工具( tool)和SCANNOW命令。您可能还想尝试使用CHKDSK命令进行驱动器错误检测。
为数据恢复付费(Pay For Data Recovery)
最后的手段是获得专门的文件恢复软件(几乎总是付费)或聘请数据恢复公司来重建尽可能多的数据。这是非常昂贵的,只有当数据的价值远远超过恢复成本时才值得这样做。因此,在拿出信用卡购买文件修复软件之前,通常值得进行故障排除。
如果您没有经历过数据损坏,那么现在实施我们上面列出的一些预防措施还为时不晚。即使只是为了您最有价值和不可替代的数据。
What Is a Corrupted File and How Can I Fix It?
File corruption is a form of accidental or unintended damage to the data in a file. File corruption comes in many shapes and happens for varіous reasons, but thе result is the same: you can’t read your datа.
In some cases, you can reverse or repair file corruption, but that’s not always possible. It’s better to understand why corruption can happen and how you might be able to safeguard against it.
What Does It Mean for Files to be Corrupted?
A “file” is a collection of related data that should be read as a unit, written in a specific file format. For example, all the data in a Microsoft Office Word file is related to the Word document you created and stored in the .docx file format. If half the file were suddenly unreadable, you probably wouldn’t be able to open your document. Even if you could, lots of information would be missing. Likewise, an Excel spreadsheet with random values missing or changed would be worthless.
Any computer file consists of binary code. It’s a string of ones and zeros grouped into sets of bits, which represent data such as a letter.
In ASCII code, the letter “A” is represented by the binary code 01000001. If we change a single bit, such as the last 1 into a 0, then the “A” becomes an “@”!
This is how corruption works at a basic level. The values of bits inside a file are changed or erased, leading to an unreadable or only partially readable file.
How to Tell if File Corruption Has Occurred
File corruption can have various symptoms, depending on which files have been corrupted and how important they are.
CRC Errors
Cyclic Redundancy Check (CRC) checks whether a file is whole and correctly stored. CRCs apply a formula to the data in the original pristine file, which results in a number as the output. If you apply the same formula to any copy of that file, that number should be the same. If the number is different, you’re dealing with a damaged or altered file.
You’ll most often see this error when trying to copy data from a damaged optical disk or dying hard drive, but many apps can give a CRC error when they self-check their files against a table of correct values.
File Opening Errors
If a file is corrupted, it either won’t open or will open with garbled results. Some file types are streamed and somewhat tolerant to damage. For example, if you have a video file with some corruption, media player apps may show picture breakup or stutter, but otherwise, play the entire file.
Other types of files, such as program executables, have to be 100% whole, or the program will not start.
And other file types, such as documents you’ve created, may open but be missing vital information, such as actual values from the document or formatting.
Strange Behaviors and Glitches
When resource or settings files that an application needs become corrupted, they may show up more subtly. The program won’t necessarily fail to start, but some subcomponents that rely on those files could give errors, do nothing, or crash the whole application.
System Crashes and Instability
When you get corrupted system files, it can fundamentally affect your computer. You may get sudden seemingly random BSODs (Blue Screen of Death) computer crashes or have a system that hangs or doesn’t work the way it’s meant to. Critical file corruption of this type is the most devastating and can often point to a severe problem with your hardware in many cases.
Why Does File Corruption Happen?
Now we know what corruption is, but how does it happen?
Although corruption is just the alteration of bit values chaotically and destructively, the causes of those changing values vary a great deal. This is mainly because computer media comes in many different forms and stores binary digits in very different ways.
Sudden Power Loss
One of the most common reasons a storage device experiences file corruption is a sudden power outage. This is especially true of mechanical hard drives, where cutting the power while writing to the disk can wipe out data. In the past, the read/write head of the disk could crash into the platter if they lost power, but modern drives can still safely “park” their heads even when the power suddenly goes out.
This does not mean that mechanical or solid-state drives are impervious to corruption through data loss. If the drive was actively writing data when the power went out, only part of the file might have made it into the disk. Both types of drives use volatile cache memory. This means the data inside them is lost if the power goes out.
Hardware Failure
All storage media have limited lifespans. They can wear out or begin to malfunction. Sometimes, this failure happens slowly over time, and sometimes, it’s sudden. Anyone who has dealt with mechanical hard disks knows the dreaded “click of death” many drives make before dying a short while later.
It’s not just hard drives, either. Faulty RAM can cause data corruption as the wrong values are written to the disk, scratched optical disks can be unreadable thanks to the physical damage, and so on.
Malware
Malware includes any software written with deliberate malicious intent. Data corruption or destruction resulting from malware infection can be by design or by accident. Malware authors don’t have much motivation to destroy your data for the most part. Instead, they’d hold it hostage for money (ransomware) or steal it to sell on the black market.
In some cases, malware is written simply to sow chaos and destruction. Malware designed to corrupt or destroy data usually does so in a way that’s virtually impossible to recover.
Preventing and Reversing File Corruption
It’s always better to prevent corruption from affecting you in the first place, but there are also ways to reverse it in some cases.
Check Disks for Errors
You can use various Microsoft Windows and third-party utilities to check for current errors such as bad sectors on your drives. You can also use utilities to diagnose the drive’s operational logs to predict whether the failure is imminent, giving you time to move that data elsewhere.
Check out How to Check Your Hard Drive for Errors for detailed instructions.
Make Frequent Backups
“Backing up” data describes a wide variety of practices. These include cloning your entire drive in case it fails, creating ZIP file archives, backing up specific files to the cloud, automatically making incremental backups to an external drive, and more. If you have recent data backups, then corruption becomes an annoyance rather than a disaster.
If you want to know more about making backups, we have several valuable guides:
These should have you covered for backups on modern Windows systems, but macOS users can check out our Time Machine guide.
As an added precaution, you can also manually create a System Restore point to roll back to a previous version of your Windows installation before destructive file changes not related to hardware failure.
Use File Verification Features
Some software clients can also run file verification operations. For example, the Steam video game client can check whether a game’s files have been altered and restore the original data from a master online copy.
Eject Drives Before Removing Them
Regardless of the disk type or operating system, you should eject drives before unplugging them. At the very least, wait until the disk activity light has stopped before unplugging it, but ideally, take a second or two to eject a flash drive or external hard disk.
Use Antivirus Software
If you don’t want malware-related corruption, use antivirus software. There are several options for Windows, macOS, and Linux.
Use the System File Checker (SFC)
In some cases, you can determine if corruption has happened to your files and repair them automatically. Windows has several file repair tools to fix corrupted Windows system files, such as the System File Checker. You can get the exact details in our guide to Using the Command Prompt Commands to Fix or Repair Corrupt Files, which also covers the DISM tool and SCANNOW command. You may also want to try the CHKDSK command for drive error detection.
Pay For Data Recovery
The last resort is to get specialized file recovery software (almost always paid) or hire a data recovery company to reconstruct as much of your data as possible. This is very expensive and only worth doing if the value of the data far exceeds the cost of recovery. So it’s usually worth troubleshooting things before pulling out your credit card to buy file repair software.
If you haven’t experienced data corruption, it’s not too late to implement some preventative measures we listed above. Even if only for your most valuable and irreplaceable data.