c# - Move File To Sub-Directories -


moving files easy & clear in .net gets me how move sub-directory example, let's have file in source destination called joe_2.mp3, , need move destination directory , modified sub-folder if 1 exists. if not move straight destination directory. how 1st check sub-directories & if exist find modified 1 , move source file their?

this using when straight move directory1 directory2

private string source = @"c:\\first\\"; private string unclear = @"c:\\second\\"; public form1() {   initializecomponent(); }  private void button1_click(object sender, eventargs e) {   directoryinfo firstcheck = new directoryinfo(@"c:\\first\\");   directoryinfo secondcheck = new directoryinfo(@"c:\\second\\");   ienumerable<string> list1 = firstcheck.getfiles("*.*").select(fi => fi.name);   ienumerable<string> list2 = secondcheck.enumeratefiles("*", searchoption.alldirectories).select(fi => fi.name);   ienumerable<string> missing = list1.except(list2);   foreach (var file in missing)   {     var subdi = new directoryinfo(secondcheck.tostring());     var direcetories = subdi.enumeratedirectories().orderby(d => d.creationtime).select(d => d.name).tolist();     file.move(source, unclear);   } } 

use directory.getdirectories paths of subdirectories, use directory.getcreationtime info need. can sort them , take minimal value matches criteria.


Comments

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -