This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I need to copy a set of files and directories to another location, but the directories don't exist in the new location. As such, I get an error that they don't exist. I need the copy process to copy files and directories recursively, creating directories as needed. I have checked the task documentation, but I can't seem to come up with a simple way to do this. Any suggestions?
Have you taken a look at the mkdir task? It allows you to create directories.
Joined: Apr 03, 2002
Sure - I use mkdir all the time. The problem is in copying a set of files and directories that I don't know the composition of - I want to pick them up and copy them without having to know what sub-directories exist.
Yes, if you use mkdir task to create the top level that you want to copy into the copy task should take care of the rest. One thing you might do is create an init task that will create the top level directories and make this and other tasks which may need those directories depend on that init task.
Joined: Jun 26, 2001
You shouldn't have to know the directory structure beneath that which you are copying the copy task should handle that for you. Have I misunderstood something?
In my code I have a dependency that creates the directories [ which it sounds like may not be necessary looking at these posts] and when I use a copy task it handles the rest recursively. Here's my example:
Greg Ostravich - SCPJ2
Joined: Apr 03, 2002
Greg, I create the directories for build in my prepare task too. I have another task that blows them away too - it's nice to get a clean start from time to time.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: [ant] copy, creating directories as needed