Copying Directories System.IO.Directory class

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to copy directory contents using the System.IO.Directory class?
I want to make a full copy of one folder (files and subfolders) to another
folder.
I'm able to move the folder using Directory.Move but that removes the files
from the source folder. I see File.Copy but that only copies an individual
file.
I don't see Directory.Copy so I'm not sure if this is easily accomplished.

Thanks
 
I don't think we have this functionality in the FCL off the shelf however, you could write a very simple recursive method which does it or better still, if ur one of my types......

System.Diagnostics.Process oProcess = new System.Diagnostics.Process();
oProcess.StartInfo.FileName = "xcopy";
oProcess.StartInfo.Arguments = String.Format(@" ""{0}"" ""{1}"" /S /E /Y", source,
destination);
oProcess.Start();

..... use the good old XCopy and get the job done with minimum fuss.

HTH, Metallikanz!
 
Back
Top