
This guide demonstrates how to automate deleting large directories using batch files or directly from the command line using native Windows commands and tools, and with selected freeware GUI deletion programs that include a command line option. The command line, with less overhead, can delete complex directories in a fraction of that time, sometimes quoted as being 20 times or more faster than the traditional explorer option. But when directories have complex structures, consisting of hundreds or thousands of sub-directories and files, it may take several minutes or even hours to delete them.

Since my application is a simple bulk move for backup purposes, the recursive loop will be much quicker.Normally, deleting directories is fairly quick if they contain a modest number of sub-directories and files. But manually performing the loop is MUCH faster than robocopy, but you would have to add in all the scenarios robocopy can test for, which would then add in processing time. Now since that was using a USB2.0 device, I'm likely going to re-run this test over a network drive before really implementing it into my application. Directory.Move() that loops through the top-level folder's directories and files -> 973ms (20 run average).Recursive Routine that digs into the structure and uses FileInfo.MoveTo() -> 38,499ms (20 run average).Var files = Directory.GetFiles(MoveSource) Here was my code for a top-level move (one that doesn't dig into folder structure, compare or filter files, or log anything) var dirs = Directory.GetDirectories(MoveSource) Total elapsed time: 225,215ms (performed 1 run only because I know this operation is several minutes on average in my application using this method, so the result was well within expected)

Rc.CopyOptions.CopySubdirectoriesIncludingEmpty = true

Rc.CopyOptions.MultiThreadedCopiesCount = 1 Rc.CopyOptions.MoveFilesAndDirectories = true Using RoboSharp to perform the move operation: RoboSharp.RoboCommand rc = new RoboCommand(MoveSource, MoveDest, true)

I finally have some time to perform and report the results of my testing here for anyone in the future who might have a similar question.ĭoing a loop at the top-level if way faster.ġ94MB of files -> 2,696 Files, 87 Folders
