c# - Find Missing files and sub directories with it's files list while copy and paste? -


i copy 1 folder contains thousands of files pc mobile.due interference of files not copied.but folder size 1 gb.

so check folder size both of folders(sources destination) having kb's size difference. if copy again means it's take amount of time , need override existing files.

instead of need list files missing copy missing files. can make 1 simple exe tool this. how find missing files can 1 give guide do. don't mistake me if feel fool question.

can make 1 simple exe tool this.

of course.

how find missing files can 1 give guide do.

you need 2 lists. you'll need read , fill one, , read , compare determine what's missing. code might this:

var targetfiles = new list<string>(); foreach (var f in directory.getfiles(targetdir)) {     targetfiles.add(path.getfilename(f)); }  var missingfiles = new list<string>(); foreach (var f in directory.getfiles(sourcedir)) {     if (targetfiles.contains(path.getfilename(f))) { continue; }     missingfiles.add(path.getfilename(f)); } 

now of missing files in target in missingfiles list. can loop through list copy missing files target.


Comments