Copying Folder
Messages   Related Types
This message was discovered on ASPFriends.com 'ngfx-io' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Ambati Srinivasalu
-- Moved from [aspngfreeforall] to [ngfx-io] by Clint Barton <Click here to reveal e-mail address> --

Hi,

Can anybody direct me to sample code for Copying Folder.

Thanks

Srinivas

Reply to this message...
 
    
Mitch Denny (VIP)
Ambati,

There is no built-in method (that I could find) to copy
a directory from one location to another, but you can do
a fairly trivial copy in just a few lines of code:

    DirectoryInfo directory = new DirectoryInfo(@"C:\DIR1");
    
    foreach (FileInfo file in directory.GetFiles())
    {

        file.CopyTo(@"C:\DIR2");

    }

The problem with this code is that it won't traverse
sub-directories, and extra work is required. This is
also quite easy to do using a re-entrant method which
walks the directory tree, you just need to keep an eye
on the memory foot-print when doing this, and also
the possibility of causing a stack overflow - although
I think you would run into a limitation of NTFS before
you blew the stack in .NET :)

----------------------------------------
- Mitch Denny
- Click here to reveal e-mail address
- +61 (414) 610-141
-

-----Original Message-----
From: Ambati Srinivasalu [mailto:Click here to reveal e-mail address]
Sent: Tuesday, 4 June 2002 08:30
To: ngfx-io
Subject: [ngfx-io] Copying Folder

-- Moved from [aspngfreeforall] to [ngfx-io] by Clint Barton
<Click here to reveal e-mail address> --

Hi,

Can anybody direct me to sample code for Copying Folder.

Thanks

Srinivas
| [ngfx-io] member Click here to reveal e-mail address = YOUR ID
| http://www.aspfriends.com/aspfriends/ngfx-io.asp = JOIN/QUIT

Reply to this message...
 
 
System.IO.DirectoryInfo
System.IO.FileInfo




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com