Results 1 to 2 of 2

Thread: Copy files from one directory excluding a specific folder

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2018

    Copy files from one directory excluding a specific folder

    Hi guys, I'm trying to make a solution where I can copy over all files/folders from one directory to another but excluding a specific folder ("data"). Here's what I have so far

    Dim Paths As New ArrayList
    For Each Item As String In Paths
         If Not Item.ToString.Contains("\data\") Then
            My.Computer.FileSystem.CopyDirectory(Item, "D:\path1\path2\path3", True)
                End If
    Dim Files As New ArrayList
    For Each Item As String In Paths
        My.Computer.FileSystem.CopyFile(Item, "D:\path1\path2\path3", True)
    The theory behind this is to add all directories and folders to the array list, and if one of the items contains the data folder, then don't copy it. The result I'm getting is that it copies all the files within the folders of Directory1, and places them into Directory2 without excluding the data folder OR copying the root files in Directory1. Can anyone point out where I'm going wrong?
    Last edited by BobTarkish; Mar 8th, 2018 at 04:48 AM. Reason: Code indent format

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