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
Alex Meleta - 19 Jul 2007 17:06 GMT
Hi pamela,
See there: http://xneuron.wordpress.com/2007/04/12/copy-directory-and-its-content-to-anothe
r-directory-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
pf> What is the most current (for framework 2.0) and easy way to copy
pf> recursively
pf> all files from folder "Folder1" to folder "Folder2" ?
pf> Is there any simple function in the framework to do that?
pf>
pf> -P
pf>
pamela fluente - 19 Jul 2007 22:43 GMT
> Hi pamela,
>
[quoted text clipped - 13 lines]
> pf> -P
> pf>
Thanks. Very nice.
Bob Johnson - 19 Jul 2007 17:10 GMT
One option is to use RoboCopy... it is very powerful, free, and can be
called from batch files. Google RoboCopy to learn more.
-HTH
> What is the most current (for framework 2.0) and easy way to copy
> recursively
[quoted text clipped - 3 lines]
>
> -P
Joergen Bech <jbech<NOSPAM>@ - 19 Jul 2007 18:50 GMT
Google:
http://vbcity.com/forums/topic.asp?tid=19980
http://vbcity.com/forums/faq.asp?fid=15&cat=System
http://www.dotnet247.com/247reference/msgs/45/225766.aspx
http://www.dotnet247.com/247reference/msgs/16/83818.aspx
http://cyrilgupta.com/blog/?p=84
http://www.bubble-media.com/cgi-bin/articles/archives/000026.html
etc etc etc.
All of them suggest writing a recursive method or going
to the Win32 API.
You might want to consider if it should be possible to cancel
the operation, how the function should perform/react when
encountering large files (e.g. DVD ISO images), .lnk "folders",
large collections of files, etc. Perhaps perform the operation
on a separate thread in order not to lock up your interface for
the (unknown) duration of the recursive copy/move.
Regards,
Joergen Bech
>What is the most current (for framework 2.0) and easy way to copy
>recursively
[quoted text clipped - 3 lines]
>
>-P
zacks@construction-imaging.com - 19 Jul 2007 22:04 GMT
> What is the most current (for framework 2.0) and easy way to copy
> recursively
[quoted text clipped - 3 lines]
>
> -P
http://www.bubble-media.com/cgi-bin/articles/archives/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!)
Ben Voigt [C++ MVP] - 19 Jul 2007 23:04 GMT
> 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/library/system.io.directory(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
ShaneO - 20 Jul 2007 01:04 GMT
> What is the most current (for framework 2.0) and easy way to copy
> recursively
[quoted text clipped - 3 lines]
>
> -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.
Joergen Bech <jbech<NOSPAM>@ - 20 Jul 2007 06:02 GMT
>> What is the most current (for framework 2.0) and easy way to copy
>> recursively
[quoted text clipped - 14 lines]
>
>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
ShaneO - 20 Jul 2007 06:54 GMT
> 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.
pamela fluente - 20 Jul 2007 18:04 GMT
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