Directory.Move via Invoke Method

Hi, I am using Directory.Move (via Invoke Method) to move folders in a for loop from one location on D: to another location on X:

However, I get error “Source and destination path must have identical roots. Move will not work across volumes.”

How do I make this move directory method work?

Hi @sean.ryan ,

To make the move directory method work, you need to ensure that the source and destination paths are on the same volume.

In your case, it seems that the source is on the D: drive and the destination is on the X: drive, which are different volumes. To resolve the issue, you can copy the directory from the source to the destination and then delete the original directory from the source.

You can use the CopyDirectory activity to copy the folder from the source location to the destination location and then use the DeleteDirectory activity to delete the folder from the source location. This will effectively move the folder to the new location.

Here’s an example workflow:

  1. Use the Assign activity to set the source and destination folder paths as variables:
  • sourceFolder = “D:\folder1”
  • destFolder = “X:\folder1”
  1. Use the CopyDirectory activity to copy the folder from the source location to the destination location:
  • SourceFolder = sourceFolder
  • DestinationFolder = destFolder
  • Overwrite = True (if you want to overwrite the destination folder if it already exists)
  1. Use the DeleteDirectory activity to delete the folder from the source location:
  • Path = sourceFolder
  • Recursive = True (if you want to delete all subfolders and files within the folder)

This will effectively move the folder from the source location to the destination location.

Happy Automation, Cheers!

1 Like

Agreed to above from ABHIMANYU

As an alternate can you try:

1 Like

Hi,

Is the CopyDirectory activity used in the Invoke Method or is it just the normal activity for copy folder?

Hi @sean.ryan, It is Used in Invoke Method.

image