473,394 Members | 1,734 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.

How to Copy Entire Folder?


Hello,

I need the program I am writing to duplicate a folder, from one drive to
another drive. I need a progress report, and write-verify. What is a good
way to do that? I am using C# express, with XP.

T.I.
Jul 29 '07 #1
1 2935
Talal Itani wrote:
I need the program I am writing to duplicate a folder, from one drive to
another drive. I need a progress report, and write-verify. What is a good
way to do that? I am using C# express, with XP.
The copy logic:

private void XCopy(string dir1, string dir2)
{
string[] files = Directory.GetFiles(dir1);
foreach (string f in files) {
File.Copy(f, dir2 + f.Substring(dir1.Length), true);
}
string[] dirs = Directory.GetDirectories(dir1);
foreach (string d in dirs) {
XCopy(d, dir2 + d.Substring(dir1.Length));
}
}

For progress report you need to use a ProgressBar (remember
to update via Invoke).

Verification can be added after File.Copy.

Arne
Jul 29 '07 #2

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

Similar topics

6
by: Rob Meade | last post by:
Hi all, I have an application writing directories as and when needed, there is a template directory which contains 5 files that I need to copy into each new directory. I initially looked at the...
3
by: Steve Franks | last post by:
I think the Copy Web tool is a great idea but its implementation could use improvement. Either that or I am using it incorrectly. Basically I do not see any option to copy an entire site in one...
2
by: kevin | last post by:
Greetings. I am well aware that visual studio.net (vb.net) has the option of using their custom installer software, but i insist on creating my own. I am relatively new, and so i am looking...
1
by: kevin | last post by:
Greetings, I am looking for an efficient way to copy an entire folder into a path. I looked all over MSDN and found ways to copy files individually, but i have a folder with lots of sub...
2
by: Xavier Valdés | last post by:
Hi all, I would like to copy FILES from the clipboard to a desired folder from VB.NET. I was able to copy files (with filedrop data format) to the clipboard but I don't know how to catch this...
2
by: =?Utf-8?B?SmltIFdhbHNo?= | last post by:
I'm new to .NET development, although I have worked with VS2005 and VC++ for a while. A frequent task for me is to create a new project for a new version of my program, without destroying the...
1
by: =?Utf-8?B?Y2FzaGRlc2ttYWM=?= | last post by:
Hi, I have seen many examples of moving a folder to a new location, but is there a way to simply copy it instead? For example, I want to copy the contents of folder C:\Testing\Stuff to...
4
by: Tom | last post by:
Every week our web guys publish the web site to all of our servers by logging into the server and doing a copy - paiste. We want to elminate the developers from logging into each server and doing...
4
by: jodleren | last post by:
While reading php.net I found " bool copy ( string $source , string $dest ) Makes a copy of the file source to dest . If you wish to move a file, use the rename() function. " ..... what?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.