Copying a folder with contents leads to exception

I am having trouble trying to copy a folder with contents (subfolders and files) to another folder.

My source folder:

image
(alsdfjk asdf also contains 1 files)

My target folder:

Here is my file:

As soon as I hit copy it tells me that one of the files in the subfolder (presumably the first file it encounters) already exists, even though the target folder was empty to start with.

Any help is much appreciated.

copy_folder_bug.vl (4.6 KB)

Okay, it seems the easiest solution is to use the VisualBasic implementation of CopyDirectory. It might seem like a simple task, but its surprisingly difficult to copy a folder with subfolders into another folder (and obviously a lot that can go wrong if you are not careful).

Even though it is a Visual Basic method, it’s actually part of .NET.

So you can add Microsoft.VisualBasic.Core.dll as a file reference (its in the vvvv folder in “refs”).

Now you get CopyDirectory as a node and it just takes a string for source and one for target. It works great!

The finished implementation in context:

1 Like

There is also this nuget:

2 Likes