I already create code for copy but I don't know how to combine copy code if the filename are not in jpeg,bmp,png or gif it will copy to different folder name(C:\Dump) but if filename extension exists file will be copy into (C:\Destionation).
public static void CopyFile( string[] args ) { CopyFolder( @"C:\source", @"C:\Destination" ); Console.ReadLine(); } static public void ProcessDirectory(DirectoryInfo directory) { foreach (FileInfo file in directory.EnumerateFiles("*.jpg,*.bmp,*.png,*.gif,*.jpeg")) { //how to combin process directory info with copy folder statement// } } static public void CopyFolder( string sourceDir, string destFolder ) { if (!Directory.Exists( destFolder )) Directory.CreateDirectory( destFolder ); string[] files = Directory.GetFiles( sourceDir ); foreach (string file in files) { string name = Path.GetFileName( file ); string dest = Path.Combine( destFolder, name ); File.Copy( file, dest); } }
Enumerate("*.*")then switch destination according to extensionfile.Extension.Equals(".jpg")or - better - simply keep a list of them. A case insensitive search for that extension will give tell you if you have to copy indump" ordestination".