[Solved] Move Files That Do Not Exist


For sure you don’t want to create text files listing file names, and then compare them. That will be inefficient and clunky. The way to do this is to walk through the source directories looking for all the files. As you go, you’ll be creating a matching destination path for each file. Just before you copy the file you need to decide whether or not to copy it. If a file exists at the destination path, skip copying.

Some enhancements on that might include skipping copying only if the file exists and the last modified date/time and file size match. And so on, I’m sure you can imagine variants on this.

One thing that you might not want to do is build a list of all the files first, and then start copying. It may very well be more efficient to copy files as you are iterating over the source directory. For example you could use Directory.EnumerateFiles to do this in an efficient way.

Of course, you don’t need to write a program to do this. Thousands already exist, some of which are quite effective.

solved Move Files That Do Not Exist