|
-
Dec 6th, 2002, 10:04 PM
#1
Thread Starter
Lively Member
Folders
How do I copy the contents of an entire folder to a new folder with a differnet name?
Can this be done?
-
Dec 7th, 2002, 08:19 AM
#2
Fanatic Member
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
- Use the thread tools to Mark your Thread as Resolved when your question is answered.
- Please Rate my answers if they where helpful.
-
Dec 7th, 2002, 09:52 AM
#3
Registered User
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
-
Dec 7th, 2002, 02:15 PM
#4
Thread Starter
Lively Member
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?
-
Dec 7th, 2002, 02:42 PM
#5
Thread Starter
Lively Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|