I am new no .net programming in C# currently I am developing a project in which I want to a functionality that is when a file is deleted I can move this file to my custom folder named recovery but i do not know how to do this please help me. I want to use SHFileOperation to do this job.
Asked
Active
Viewed 1,449 times
0
-
Why not using [System.IO.File.Move(...)](http://msdn.microsoft.com/en-us/library/system.io.file.move.aspx), but SHFileOperation? – Apr 17 '14 at 06:43
-
Actually, rather use [System.IO.Directory.Move(...)](http://msdn.microsoft.com/en-us/library/system.io.directory.move.aspx), as this can move both files and directories. – Apr 17 '14 at 06:52
-
If you want to automatically copy a file before it is deleted by some other process (as suggested by the answers given here already), then though luck: You are in for some advanced programming tasks. Just for getting you in the right mood, look here: http://stackoverflow.com/questions/10727844/intercept-filesytemcall-for-deletion or here: http://forum.sysinternals.com/deletefile-hook_topic23634.html – Apr 17 '14 at 13:54
-
Directory.Mode() cannot move to a different volume, e.g. from C:\ to D:\ – Kim Homann Aug 05 '20 at 11:20
1 Answers
-1
You may use FileSystemWatcher, listen to OnDelete event, then copy to custom folder. http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher(v=vs.110).aspx