I did not bother to name this...

From Unreliable Peccary, 3 Weeks ago, written in C#, viewed 33 times.
URL http://codebin.org/view/1fd939fb Embed
Download Paste or View Raw
  1. using System;
  2. using System.IO;
  3.  
  4. namespace Struct
  5. {
  6.     class Program
  7.     {
  8.         static void CopyAll(DirectoryInfo oldDI, DirectoryInfo newDI)
  9.         {
  10.             foreach(FileInfo fi in oldDI.GetFiles())
  11.             {
  12.                 Console.WriteLine(@"Copying {0}\{1}", newDI.FullName, fi.Name);
  13.                 fi.MoveTo(Path.Combine(newDI.ToString(), fi.Name));
  14.             }
  15.             foreach(DirectoryInfo diSubDir in oldDI.GetDirectories())
  16.             {
  17.                 DirectoryInfo nextTag = newDI.CreateSubdirectory(diSubDir.Name);
  18.                 Console.WriteLine(nextTag);
  19.                 CopyAll(diSubDir, nextTag);
  20.             }
  21.            
  22.         }
  23.         static void Main(string[] args)
  24.         {
  25.             string oldPath = @"./";
  26.             string newPath = @"../";
  27.  
  28.             DirectoryInfo oldDI = new DirectoryInfo(oldPath);
  29.             DirectoryInfo newDI = new DirectoryInfo(newPath);
  30.  
  31.             CopyAll(oldDI, newDI);
  32.  
  33.             Console.ReadKey();
  34.         }
  35.     }
  36. }
  37.  

Reply to "I did not bother to name this..."

Here you can reply to the paste above