How to copy a folder?

I have to copy a folder and then paste it in another location. Can anyone help me with this?

@apriyam use send hotkey activity

use start process activity and point out cmd.exe

image

this example for Delete a directory. you can change the command as per your need

1 Like

You can try this:

  1. Store the path of files in array of string.
    string FileArr = Directory.GetFiles(filePath); //use assign activity
  2. For each fileValue in FileArr
    Use copy activity with inputs as source - fileValue and target - targetPath.

This will copy all the files from one folder to another.

2 Likes

Hi palindrome,

Does copy file work with folders as well?

I am facing an problem when I point the full path of the folder as source, it gives an Access Denied. While, when giving the full path of a file, on same location, it successfully copies the file.

hi ddrdushy1,
could you kindly suggest what strategy to use to check if command execution is successful?

thanks

based on the command it vary. i usually use while loop after command prompt.something like this.

image

1 Like

Check out the workflow posted by ‘Suchi3190’, it works perfectly fine

2 Likes

I’m sure you have already solved the problem but I made a workflow that will help future users out.Copy Directory.xaml (5.4 KB)

1 Like

Hi @apriyam
You can use Invoke Method activity For It, and in the Target Type give Microsoft.VisualBasic.FileIO.FileSystem and in the properties give the source path and destination path in Parameters.
Thanks & Regards

Hi,
The xaml example copy folders and files from a folder to another folder.
Is there anyway to just copy folders only from a folder to another folder ?
Don’t copy the files in the folder.

Hey @jitendra_123

please attach .xaml for same. I am facing problem where to write source/destination path

Hi @Purvi
Find the attachments I have done it multiple ways you can go through it.CopyFilesDynamic.xaml (8.6 KB)CopyFoldeUsingInvokeMethod.xaml (5.8 KB)