static void RetriveFiles(DirectoryInfo srcDir, DirectoryInfo finalDir, string type) { FileInfo[] files = srcDir.GetFiles("*" + type); foreach (FileInfo file in files) { file.MoveTo(finalDir.FullName); } DirectoryInfo[] directories = srcDir.GetDirectories(); foreach (DirectoryInfo subdirectory in directories) { RetriveFiles(subdirectory, finalDir, type); } }
Monday, July 12, 2010
Retrieving Files by Type - C#
The following code searches a given directory and all subdirectories for files of a certain type and moves them to a specified directory.
Labels:
C#,
C# Sample Code
0 comments:
Post a Comment