The most common mistake people make is thinking that the deletion of a file means its immediate erasure from the drive. Even I used to think that way before discovering the truth. It is because of the fact that even a very large file disappears on the screen instantly. The reality is that it doesn’t immediately erase, instead, the operating system removes the pointer to the record of that particular file and marks the space on the drive as available for fresh data storage.
This makes the data still present on the drive until such space is re-used by later writes of any kind. The moment when I realize that I have accidentally deleted something crucial becomes critical. Even using that drive can lead to overwriting of the deleted data, unless it is done by accident. Browsing the web with a browser can write data on the drive and so can the operating system itself.
If the files I deleted were found on the system drive, it would be best to restart the computer as soon as possible. To help myself, I can use another computer, while trying to avoid overwriting the drive on which the deleted files are residing. If the deleted files were on the system drive, it will be helpful to boot the other computer from a flash drive. The other disk can be connected as a second disk, which will minimize the number of writes to the drive with deleted data.
When the drive is disconnected, the file recovery application can recover all the data that could be recovered. It does this by searching for content that does not have records of pointers. It attempts to recover these files by rebuilding the found content. File recovery becomes almost complete when the time between deletion and discovery is short. In addition, the recovered files are often found in their original locations with their original names.
There are other cases, when the recovery is more complicated. These happen when the newly available space on the drive has already been partially overwritten. There might be a situation, when a file that has already been partially overwritten will be recovered to a different location with a generic name. Sometimes, the actual content of the deleted file can survive, while the record of it has already been overwritten. Then the file is found by the software, but it has to be somehow identified.
The storage medium makes a big difference as well, since modern SSDs employ a mechanism of TRIM to mark the abandoned blocks for erasure. This action can be done at any time, when the system decides it is necessary. When this happens, the data recovery from an SSD becomes significantly more difficult. It can be complicated to recovery any data that is on an SSD drive that has been deleted. The process can be very time-consuming and even fail, if the time between deletion and recovery is more than a few days.
The memory cards and USB sticks are more similar to traditional hard drives. Their internal workings are roughly similar to those of traditional hard drives, so the data on them can survive for weeks or months. This is why it is sometimes possible to recover photos that have been deleted from a camera card several weeks ago.
None of this is guaranteed, since all of the above is an emergency measure. It is not a substitute for regular backups of the folders that are of particular importance to me. Those would allow me to recover lost files in a couple of minutes, rather than try and fight with the file recovery software.