How to move a directory and its files to a new path

I´m trying to move a direcotry with its files to another path using “copy file”, but it doesn´t work. copy file

1 Like

You can create a new folder and use Move File (using foreach)

or you may use

Directory.Move(sourceDir, destinationDir);

3 Likes

Thank you @vvaidya. I want to use the second option, Directory.Move(sourceDir, destinationDir); but I don’t know where I have to put that instruction because it doesn´t return any value

1 Like

Hi ELanchas.

You can use the activity invoke method, in the Programming -> Execute -> Invoke Method.
Here is another topic that might give you more information on how to use it. Move a file or Rename a file

Note : Using the “move” it moves the file . It’s != copy. Make sure you know what you need.

Regards.

2 Likes

Use below method, please note destination folder should not exist

6 Likes

Thank you @vvaidya, @Pedro_Pereira,

it works perfectly. Really I want to copy the directory, not move, but it seems that copy method doesn´t exist for Directory.

Regards,

1 Like

Folder Copy needs to by done file by file (foreach)

2 Likes

Hi @vvaidya @ELanchas
Could you please share the sample project with us? regarding the folder move !!!

Thanks.

1 Like

i tryed this methode but it says: Move did not exist in system.IO.directory

we can use Copy Directory method of FileSystem. here is the exampleCopyLogs.xaml (7.4 KB)

If destination folder is exist even though it will execute.

6 Likes

Please see following thread, looks similar to me.