6

Is there a way to recover file(s) that have been deleted programatically by the File.Delete() method?

Deleted files do not appear in the recycle bin.

DevDave
  • 6,700
  • 12
  • 65
  • 99

2 Answers2

10

Nope. File.Delete() calls a hard delete within the API and by-passes the Recycle Bin. You will need to use a file recovery program and hope for the best.

For deletion via the Recycle Bin you use the SHFileOperation API as it is part of the shell.

If/once you have your files back you might want to take a look at this SO answer which discusses changing File.Delete() to something that uses the Recycle Bin:

Send a File to the Recycle Bin

Community
  • 1
  • 1
Lloyd
  • 29,197
  • 4
  • 84
  • 98
  • It's always been one of my frustrations that there's no corresponding method in the file namespace, ex. File.Recycle for this operation. Resorting to unmanaged code or VisualBasic's namespace always seemed like a bad compromise. – Reacher Gilt Jan 07 '13 at 17:11
3

No, directly there is no way to recover it.

You can use a recovery program or API to get your files.

If the files are important I would shutdown the computer right away.

Take a look at this: C# classes to undelete files?

Same problem with answer.

Community
  • 1
  • 1
jAC
  • 5,195
  • 6
  • 40
  • 55