473,473 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Copy all files from a folder to another folder, recursively


What is the most current (for framework 2.0) and easy way to copy
recursively
all files from folder "Folder1" to folder "Folder2" ?

Is there any simple function in the framework to do that?
-P

Jul 19 '07 #1
9 3568
Hi pamela,

See there: http://xneuron.wordpress.com/2007/04...irectory-in-c/

No easy way, except, probably, Process.Start("xcopy", "c:\old c:\new /O /X
/E /H /K") or Win API functions.

Regards, Alex
[TechBlog] http://devkids.blogspot.com

pfWhat is the most current (for framework 2.0) and easy way to copy
pfrecursively
pfall files from folder "Folder1" to folder "Folder2" ?
pfIs there any simple function in the framework to do that?
pf>
pf-P
pf>
Jul 19 '07 #2
One option is to use RoboCopy... it is very powerful, free, and can be
called from batch files. Google RoboCopy to learn more.

-HTH

"pamela fluente" <pa***********@libero.itwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
>
What is the most current (for framework 2.0) and easy way to copy
recursively
all files from folder "Folder1" to folder "Folder2" ?

Is there any simple function in the framework to do that?
-P

Jul 19 '07 #3
On Jul 19, 11:20 am, pamela fluente <pamelaflue...@libero.itwrote:
What is the most current (for framework 2.0) and easy way to copy
recursively
all files from folder "Folder1" to folder "Folder2" ?

Is there any simple function in the framework to do that?

-P
http://www.bubble-media.com/cgi-bin/...es/000026.html

Try it and let us know how it works! (I haven't, I just found it with
a Google search to answer your question, but I can see the use for
it!)
Jul 19 '07 #4
On 19 Lug, 18:06, Alex Meleta <amel...@gmail.comwrote:
Hi pamela,

See there:http://xneuron.wordpress.com/2007/04...and-its-conten...

No easy way, except, probably, Process.Start("xcopy", "c:\old c:\new /O /X
/E /H /K") or Win API functions.

Regards, Alex
[TechBlog]http://devkids.blogspot.com

pfWhat is the most current (for framework 2.0) and easy way to copy
pfrecursively
pfall files from folder "Folder1" to folder "Folder2" ?
pfIs there any simple function in the framework to do that?
pf>
pf-P
pf>
Thanks. Very nice.

Jul 19 '07 #5

"pamela fluente" <pa***********@libero.itwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
>
What is the most current (for framework 2.0) and easy way to copy
recursively
all files from folder "Folder1" to folder "Folder2" ?

Is there any simple function in the framework to do that?
The framework seems to have a hole there. Notice how on this page:
http://msdn2.microsoft.com/en-us/lib...ry(VS.71).aspx

"Copy a directory" has no example. Then click to the 2005 or Orcas version
of the page... "Copy a directory" is gone.

p/invoke to http://msdn2.microsoft.com/en-us/library/ms647743.aspx
>
-P

Jul 19 '07 #6
pamela fluente wrote:
What is the most current (for framework 2.0) and easy way to copy
recursively
all files from folder "Folder1" to folder "Folder2" ?

Is there any simple function in the framework to do that?
-P
I don't know if I'm missing something here, but why not just use the
FileSystem.CopyDirectory(SourceDIR, DestinationDIR) method?

If your reason for wanting it done "Recursively" is because you want to
monitor the progress or trap for errors, then just use some of the
available options provided by this Method.

See "CopyDirectory method" in Help for full details.
ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Jul 20 '07 #7
On Fri, 20 Jul 2007 10:04:39 +1000, ShaneO <sp****@optusnet.com.au>
wrote:
>pamela fluente wrote:
>What is the most current (for framework 2.0) and easy way to copy
recursively
all files from folder "Folder1" to folder "Folder2" ?

Is there any simple function in the framework to do that?
-P
I don't know if I'm missing something here, but why not just use the
FileSystem.CopyDirectory(SourceDIR, DestinationDIR) method?

If your reason for wanting it done "Recursively" is because you want to
monitor the progress or trap for errors, then just use some of the
available options provided by this Method.

See "CopyDirectory method" in Help for full details.
ShaneO
Kind of a half-baked method. No filter options and
stuck in the VisualBasic namespace rather than the core
framework. No options for recursion depth either.

But perfect answer to the original question.

Regards,

Joergen Bech

Jul 20 '07 #8
Joergen Bech <jbech<NOSPAM>@ wrote:
Kind of a half-baked method.
"half-baked"??? It is a fully mature method, can't see what's
half-baked about it? I can write complex Win32 API calls to accomplish
tasks or purchase 3rd party add-ins just as much as anyone, but choosing
to use, say, the "File.Open" method doesn't make that half-baked in my
opinion! :-)
No filter options
None were requested. OP wants to copy "all files"
stuck in the VisualBasic namespace rather than the core
framework.
Only just noticed the OP cross-posted. If a VB question is posted then I
guess a VB solution can be expected to be received.
No options for recursion depth either.
Once again, not requested.
But perfect answer to the original question.
I'm glad you see it as I did.

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Jul 20 '07 #9
I used the recursive code in the xneuron link provided by Alex above.
Is simple, flexible and works perfectly.

Just added a few things like dovents and some messaging and checks. I
recommend it.
-P

Jul 20 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Antonio Lopez Arredondo | last post by:
hi all !!! I need to copy a folder and its subfolders to another location; which class should I use ? could only find the System.IO.Directory.MOVE but don't know how to COPY. thanks in...
2
by: melo | last post by:
Hello, I've been struggling with a function(s) to recursively set all folders and files to NOT read-only. So, I thought I'd post this message. What I need to do is: given a starting path, I...
3
by: Johnny | last post by:
Hi, I have created an ASP.NET application (let's call it FooBar) with VS.NET on my local machine, residing in http://localhost/FooBar. Deploying it to another folder on my machine works well...
6
by: ad | last post by:
I want to copy all files under a folder to another folder. If I use File.Copy(sourceFileName, destFileName, overwrite), it must specify all files name in the source and destionation. How can I...
1
by: Dan | last post by:
I have an application that I want to use for copying files. My goal is to copy a files, if a file is in use or not accessible because of security reasons I want to make note of that file then...
2
by: TwistedPair | last post by:
All, This is sort of a continuation of a previous post of mine. The code below basically reads a registry key to get a path to a folder and it watches for files created in that folder (only...
1
by: Andrew Koenig | last post by:
The answer to this question probably involves pywin32 or a similar library. I would like to copy a file from one place to another on a Windows machine while preserving as much of the file...
9
by: pamela fluente | last post by:
What is the most current (for framework 2.0) and easy way to copy recursively all files from folder "Folder1" to folder "Folder2" ? Is there any simple function in the framework to do that? ...
3
by: usman | last post by:
Hi I have a windows service that backups a folder onto another location on the same computer. The service is written in C#. The size of the original folder is large i.e. over 8 GB. Also the...
1
by: kumarboston | last post by:
Hi all, I am trying to copy couple of directories and their files to another place. Each directory have 25-30 files and numbered accordingly, the problem I am facing is, I have to copy files...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.