Move Folder to another Folder


#1

Hi ,

I want to move a folder to another location.
Eg: I have folder C:/Level1/Level2.
I need to move this Level2 folder to C:/Level1/Target.
‘Target’ Folder already exist with other files/folders.
so once done I should find ‘Level2’ in C:/Level1/Target/Level2

Please Note - Its move not copy.

Please provide your suggestions


#2

Hey @Deeipauk,

Maybe these links can help you :slight_smile:


#3

Thanks for your reply Rishabh.

In both the cases its given the destination folder should not exist already but in my case the destination already exist with other files/folders. In that destination I need to move some more folders


#4

Hi @Deeipauk,

Try using

Directory.Move(sourceDirName, destDirName)


Copy directory to another directory
#5

In that case you will need to loop through the files in the folder and copy those to the new folder.


#6

where to write this code? in assignment statement? if you dont mind please provide me some sample .xaml


#7

Thanks for your reply. This will complicate the process.I need to first create a new directory with the same name and move files one by one also internally it may contain sub folders also. So i feel this will complicate?

Correct me if I am wrong


#8

As @sarathi125 suggested, Directory.Move method moves a directory and all its contents, including nested subdirectories and their files, to a new location and if the destination directory already exists, an error occurs.
You cannot use assign activity because return type of this method is none.
You can write this code in invoke method activity with the following options:

  1. Target Type as System.IO.Directory
  2. Method Name as Move
  3. Two parameters in property panel with In and String Type for SourceDirectory and DestinationDirectory.

DirectoryMove


#9

Thanks for your reply

“Invoke Code” – is this the activity I need to use?
When i look at screen shot shot this looks like “Invoke Method” which will throw error since the destination diretiry already exist.

If you don’t mind please provide a sample .xaml


#10

Hello @sarathi125.
How can this be done?
Thank you so much,
Camilla