views:

1564

answers:

3

Is there a way to copy an entire directory to the output directory in a console application in C#.NET?

I know for files you can right click them, properties and mark copy to output directory. But I'm not going to do that for 20.000 files...

Thx, Lieven Cardoen aka Johlero

A: 

You could hit ctrl+A to highlight all of them, then hit ctrl+C to copy them, then go to the new directory and hit ctrl+V to paste them all to the new location...

Or you could open up the command window and use copy... but the first way is probably easier.

Telos
+2  A: 

Are you sure you want all 20000 files in the output?

Besides manual copy-paste operation I see two options: one is you can have a post-build task to copy all the files and another is to have 20000 files zipped, zip file added as a content item to your project with "copy always" set and either console application unzip 'em, or a post-build step is calling unzip utility to do that.

+2  A: 
  1. While in development, use application configuration to point to where these files CURRENTLY reside, instead of copying them. (copying that many objects on each build is a nightmare. Even if copying only new/updated files)

  2. When preparing a release build, you might want to consider using a build script and MSBuild or NAnt to do this type of thing for you.

  3. If you REALLY are convinced you are sure you still want to perform a copy on each build - use Post/pre-build script (in your project build configuration, point to a batch file which performs an xcopy.. some smart batch scripting can sometimes be very helpful).

Yoni Shalom