How do I copy the contents of an entire folder to a new folder with a differnet name?
Can this be done?
Printable View
How do I copy the contents of an entire folder to a new folder with a differnet name?
Can this be done?
use a for-loop that copies all the files from a folder to a specified other folther.
In vb6 a function existed that uses the file system object, copyfolder or foldercopy or somthing like that. Don't know about that in vb.net
Something like this maybe....
Code:Dim folder1 As New DirectoryInfo("C:\Test")
Dim folder2 As New DirectoryInfo("C:\Test2")
folder2.Create()
Dim file As FileInfo
For Each file In folder1.GetFiles
file.CopyTo(folder2.FullName & "\" & file.Name)
Next
This works just fine except it tries to copy the file multiple times and thus produces an error message saying the file already exists in this folder!
Any suggestions?
Well I think I figured it out! Im using a Timer to create an instance to perform this operation and thats what screwing it up!