Results 1 to 5 of 5

Thread: Folders

  1. #1

    Thread Starter
    Lively Member flog3941's Avatar
    Join Date
    Nov 2002
    Posts
    123

    Folders

    How do I copy the contents of an entire folder to a new folder with a differnet name?
    Can this be done?

  2. #2
    Fanatic Member robbedaya's Avatar
    Join Date
    Jul 2002
    Location
    Belgium
    Posts
    872
    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.

  3. #3
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    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

  4. #4

    Thread Starter
    Lively Member flog3941's Avatar
    Join Date
    Nov 2002
    Posts
    123
    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?

  5. #5

    Thread Starter
    Lively Member flog3941's Avatar
    Join Date
    Nov 2002
    Posts
    123
    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
  •  



Click Here to Expand Forum to Full Width