Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I undelete a file using C#?

I'm trying to find some lost .jpg pictures. Here's a .bat file to setup a simplified version of my situation

md TestSetup
cd TestSetup
md a
cd a
echo "Can we find this later?" > a.abc
del a.abc
cd..
rd a

What code would be needed to open the text file again? I'm actually looking for .jpeg files that were treated in a similar manner

More details: I'm trying to recover picture files from a previous one-touch backup where the directories and files have been deleted and everything was saved in the backup with a single character name and every file has the same 3 letter extension. There is a current backup but they need to view the previous deleted ones (or at least the .jpg files).

Here's how I was trying to approach it: C# code

like image 396
Fred Avatar asked Feb 28 '23 08:02

Fred


1 Answers

To the best of my knowledge, most file recovery tools actually read the low-level filesystem format on the disk and try to piece together deleted files. This works because, at least in FAT, a deleted file still resides in the sector specifying the directory (just with a different first character to identify it as "deleted"). New files may overwrite these deleted entries and therefore make the file unrecoverable. That's just a little bit of theory.

There is a current backup but they need to view the previous deleted ones (or at least the .jpg files).

Unless there's a backup for that file at the time that you want to restore from, I believe you're going to have a hard time getting that file without resorting to a low-level filesystem read. And even then, you may be out of luck if enough revisions have been made (or it's not a trivial filesystem like FAT).

like image 86
Matthew Iselin Avatar answered Mar 08 '23 10:03

Matthew Iselin