Copying a Directory

P

Phil Galey

In VB.NET, is there any way to copy a directory and all its contents to a
new location using io.Directory or io.DirectoryInfo etc. without having to
import the Scripting.FileSystemObject?

io.Directory and DirectoryInfo only seem to have a Move command, but what
about copying?
 
J

Jay B. Harlow [MVP - Outlook]

Phil,
You can use IO.File.Copy to copy a file.

I would use IO.Directory.GetDirectories to get the list of directories &
Directory.GetFiles to get the list of files in a directory. I would then use
Directory.CreateDirectory to "copy" the Directory entries & File.Copy to
copy each file.

Post if you would like a sample.

Hope this helps
Jay

| In VB.NET, is there any way to copy a directory and all its contents to a
| new location using io.Directory or io.DirectoryInfo etc. without having to
| import the Scripting.FileSystemObject?
|
| io.Directory and DirectoryInfo only seem to have a Move command, but what
| about copying?
|
|
|
 
C

Cor Ligthert

Phil,

Nobody prevents you to use XCopy in an application start.

Just my thought,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top