Copying Directories System.IO.Directory class

Copying Directories System.IO.Directory class

Post by cGF1b » Wed, 17 Aug 2005 02:34:27


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
 
 
 

Copying Directories System.IO.Directory class

Post by Metallikan » Thu, 18 Aug 2005 02:48:06

his is a multi-part message in MIME format.


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!

"paul" < XXXX@XXXXX.COM > wrote in message news: XXXX@XXXXX.COM ...
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN>> < < < < < < color=#0000ff size=>>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< < < <"paul" << href="mailto: XXXX@XXXXX.COM >< size=>> XXXX@XXXXX.COM < size=>>> wrote in message< href="news: XXXX@XXXXX.COM >< face=Verdana
size=>>news: XXXX@XXXXX.COM < face=Verdana color=#0000ff size=>>..< color=#0000ff size=>>> 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<><> Thank<