?
Solved

File.Copy Entire Directory to another Directory

Posted on 2008-11-14
6
Medium Priority
?
626 Views
Last Modified: 2013-11-07
I want to copy an entire directory to another destination. I get

Example;

            destination = "C:\jeffrey\"

            strSourcePath = "C:\moves\"
            strDestPath = destination
            File.Copy(strSourcePath, strDestPath)

Error Message;
Could not find a part of the path 'C:\moves\'.

Thanks,
Jeff
0
Comment
Question by:jseaman12
  • 3
5 Comments
 
LVL 6

Accepted Solution

by:
question earned 1000 total points
ID: 22964257
is it vb thats used for this.. i use this in a VB application of mine
My.Computer.FileSystem.CopyDirectory(SRCTB.Text, DSTTB2.Text)

SRCTB.Text, DSTTB2.Text are source and destination locations fed dynamically from TEXT box
0
 
LVL 18

Assisted Solution

by:Priest04
Priest04 earned 1000 total points
ID: 22964279
from the code I see you are using VB.NET. IF yes, then you can use this method

My.Computer.FileSystem.CopyDirectory(strSourcePath, destination)

if you are using c#, then you would need to do a recursive loop trough each subdirectory and copy all files in them.
0
 
LVL 6

Expert Comment

by:question
ID: 22966337
Was my idea helpful?
0
 
LVL 6

Expert Comment

by:question
ID: 23030192
were you able to test my solution?
0
 

Expert Comment

by:atljarman
ID: 35429746
I found this helpful.  It would be great to see how to loop through and restrict copying of specific files.  For example, if you wanted to copy all files in the directory except those that contained "secure" in the name.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question