Move Contents of Folder to new folder

I have an archive folder that has many sub folders. Each subfolder may or maynot contain contents or additional sub folders. What I need to do is to retreive each file from all levels of subfolders in C:\Archive and place in C:\Final. I do not need any subfolder in the new folder, just all files in a single level folder. I am open to C# or VB.Net does not matter. Can anyone assist?
Who is Participating?
pivarConnect With a Mentor Commented:

Try this.


public static void Main() {
      recursecopy("C:\\Archive", "C:\\Final");


    private static void recursecopy(string source, string target) {
      foreach(string folder in System.IO.Directory.GetDirectories(source)) {
        recursecopy(folder, target);
      foreach(string file in System.IO.Directory.GetFiles(source)) {
        System.IO.File.Copy(file, System.IO.Path.Combine(target, System.IO.Path.GetFileName(file)), true);

Open in new window

OB1CanobieAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.