Copying Entire Directories

Jay1b

Well-known member
Joined
Aug 3, 2003
Messages
640
Location
Kent, Uk.
I am trying to copy the contents on an entire directory to another directory.

Its doesnt like file.copy("c:\blah\*.*", "c:\blah2\")

I could do it by getting a list of every file on in the directory, then copying them one by one in a loop.

Does anybody know a better way they could please tell me?

Thanks.
 
Jay1b said:
Thanks

So basically, i need to just do it the way i was going too originally :(
I was thinking you could do something like this:



Code:
[indent]Dim proc As New Process

proc.StartInfo.CreateNoWindow = True
proc.Start("xcopy", sourceDir & " " & destDir & " /S /E /I")
While Not proc.HasExited
End While
MessageBox.Show("Done")

[/indent]
It copies the files but creates a window. . . and this line:

"While Not proc.HasExited"

immediately throws eexception "No process is associated with this object."

maybe someone has an idea???
 
Code:
[indent]Dim proc As New Process

proc.StartInfo.CreateNoWindow = True
proc = Process.Start("xcopy", """" & sourceDir & """ """ & destDir & """ /S /E /I")
While Not proc.HasExited
End While
MessageBox.Show("Done")

[/indent]

See my changes - you have to use the Static method; also note XCOPY is picky sometimes (as on my machine at least) about source and destination, and for saftey put qoutes around them.
 
Back
Top