473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 5677
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.