azareth 5 Posting Whiz in Training

I'm having this kind of error: Could not find a part of the path.

For Each subfolder As String In Directory.GetDirectories(sourceDir)
            Dim destDir As String = Path.Combine(destinationDir, Path.GetFileName(subfolder))
            If destDir = destinationDir & "\peanutButter" Then
                'do nothing
            Else
                Directory.Move(subfolder, destDir)
            End If
        Next

I suppose i get this error because the folder hasn't been made yet in destDir, but i assumed that if vb doesn't found the path it will create the folder by itself..

and i've tried adding a code to check if the folder doesn't exist, it will create then, but i get an error that this time it cannot create because the path already exists.

what i want to do is to transfer all files/folder to another folder excluding the \peanutButter folder
i've tried different approaches into making this but i always get this error

tnx,

Begginnerdev commented: +1 for figuring it out! =D +8
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.