We have an application that stores files in a temporary location until the user decides to finalize their transaction. The temp directory is unique for each transaction. Once they do finalize, the files are moved from the temp location to a final location, which is also unique for each transaction. This is all working without any issues.
I'm rather surprised, but when searching Google and SO, we were unable to find any topics on which is generally considered a best practice:
- Call System.IO.Directory.Move(src, des) to simply move the whole directory at once, or
- Call System.IO.File.Move(src, des) to move the files one at a time.
As these decisions typically rely on a number of factors, I should note the following conditions:
- The source and destination directories will always be on the same machine, but the application making the calls will be on a different machine on the same network. I believe the application server and file server are separate VM's on the same physical machine, but I am not positive.
- The number of files could range from 1 to 10, or more. I do not monitor the production system myself, so I am unsure of the average file count, or how spread the count is.