# Move/Delete a directory/folder

**URL:** <https://forum.uipath.com/t/move-delete-a-directory-folder/28583>\
**Category:** Help\
**Tags:** system, activities\
**Created:** [April 10, 2018, 8:53am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583 "2018-04-10T08:53:59Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![tzj](https://avatars.discourse-cdn.com/v4/letter/t/d9b06d/32.png) [@tzj](https://forum.uipath.com/u/tzj)\
**Post date:** [April 10, 2018, 8:54am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/1 "2018-04-10T08:54:00Z")

</div>

Hi,

I am trying to move/delete a particular folder.

Inside the folder, there are more folders, and inside those folders, they might be more folders, and finally in those folders are the files.

are there any straightforward way to just move/delete that entire top folder?

---

<div class="post-metadata">

**Author:** ![richarddenton](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/richarddenton/32/11819_2.png) [@richarddenton](https://forum.uipath.com/u/richarddenton)\
**Post date:** [April 10, 2018, 1:49pm UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/2 "2018-04-10T13:49:00Z")

</div>

The move file activity also takes a directory as a parameter so will move the whole folder.

---

<div class="post-metadata">

**Author:** ![ClaytonM](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/claytonm/32/555957_2.png) [@ClaytonM](https://forum.uipath.com/u/ClaytonM)\
**Post date:** [April 10, 2018, 2:11pm UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/3 "2018-04-10T14:11:40Z")

</div>

@richarddenton Last I knew, Move File doesn’t work for Directories and says File was not found error.

Here are some solutions I use:

> [@How to move all files in a folder to another folder](https://forum.uipath.com/t/how-to-move-all-files-in-a-folder-to-another-folder/3769/5):
>
> Try this activity if you want to, you just have to pass the source and destination(should not exisit) folder. I created for myself as I needed for bulk activities.Please test before you implment. [image] [MoveDirectory.Activities.1.0.0.nupkg](https://global.discourse-cdn.com/uipath/original/2X/4/4761ea6ac57a75493cfacf867689dbed92e0d6a6.nupkg) (42.7 KB)

> [@How to move a directory and its files to a new path](https://forum.uipath.com/t/how-to-move-a-directory-and-its-files-to-a-new-path/2662/5):
>
> Use below method, please note destination folder should not exist

---

<div class="post-metadata">

**Author:** ![tzj](https://avatars.discourse-cdn.com/v4/letter/t/d9b06d/32.png) [@tzj](https://forum.uipath.com/u/tzj)\
**Post date:** [April 11, 2018, 1:24am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/4 "2018-04-11T01:24:49Z")

</div>

i believe those wouldnt work for me case too… considering i have an unknown number of folders inside the folder i want to move.

---

<div class="post-metadata">

**Author:** ![tmays](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/tmays/32/181705_2.png) [@tmays](https://forum.uipath.com/u/tmays)\
**Post date:** [April 11, 2018, 3:18am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/5 "2018-04-11T03:18:00Z")

</div>

Hi @tzj,

Not sure why @ClaytonM’s second solution wouldn’t work but you can also move the Directory by invoking the MoveDirectory method. The TargetType is Microsoft.VisualBasic.FileIO.FileSystem.

 ![image](https://global.discourse-cdn.com/uipath/original/3X/2/4/24d4c82a5c41d6537f2380bd4013b8fecd34c258.png)

Regards  
Troy

---

<div class="post-metadata">

**Author:** ![arivu96](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@arivu96](https://forum.uipath.com/u/arivu96)\
**Post date:** [April 11, 2018, 3:42am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/6 "2018-04-11T03:42:35Z")

</div>

Hi @tmays,  
Refer this image  
 ![image](https://global.discourse-cdn.com/uipath/original/3X/4/0/405ffca59e0d44edd235aa5d3bf70f7fca7442e2.png)

Regrads,  
Arivu

---

<div class="post-metadata">

**Author:** ![tzj](https://avatars.discourse-cdn.com/v4/letter/t/d9b06d/32.png) [@tzj](https://forum.uipath.com/u/tzj)\
**Post date:** [April 11, 2018, 7:12am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/7 "2018-04-11T07:12:38Z")

</div>

can i rename the folder using the same way as moving the directory mentioned above?

the source folder name has to be fixed. i need to move it to another directory for backup. I intend to add date behind the folder name, but there is no rename activity either.

---

<div class="post-metadata">

**Author:** ![Girish](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/girish/32/18091_2.png) [@Girish](https://forum.uipath.com/u/Girish)\
**Post date:** [April 11, 2018, 7:26am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/8 "2018-04-11T07:26:47Z")

</div>

Hi @tzj,

You can use VB .net syntax to add the date behind the folder name as below:

date.today.tostring+yourpfoldername

Thanks  
Girish

---

<div class="post-metadata">

**Author:** ![arivu96](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@arivu96](https://forum.uipath.com/u/arivu96)\
**Post date:** [April 11, 2018, 7:33am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/9 "2018-04-11T07:33:19Z")

</div>

Hi @tzj,

> [@arivu96](#):
>
> Refer this image

yes you can do.

Refer the image.

in second parameter you can change the Folder name **`"C:\Users\share\Desktop\dest"`** to  
**`"C:\Users\share\Desktop\"+DateTime.Now().ToString("MM/dd/yyyy")+"dest"`**

Regards,  
Arivu

---

<div class="post-metadata">

**Author:** ![lainh](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/lainh/32/218589_2.png) [@lainh](https://forum.uipath.com/u/lainh)\
**Post date:** [April 11, 2018, 8:30am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/11 "2018-04-11T08:30:50Z")

</div>

Hi @tzj

How about [System.IO.Directory.Delete] method.  
It can directly delete your target directory .  
And the In parameter [TRUE] will remove directories, subdirectories, and files .

 ![image](https://global.discourse-cdn.com/uipath/original/3X/5/0/50be3e481e46a3e888c621348b338f786d4fc440.png)

And use [System.IO.Directory.Move] method can move the whole directory to another location.  
(just like @arivu96 has mentioned above )  
Also you can rename the folder using this mothod when move the director .

---

<div class="post-metadata">

**Author:** ![tzj](https://avatars.discourse-cdn.com/v4/letter/t/d9b06d/32.png) [@tzj](https://forum.uipath.com/u/tzj)\
**Post date:** [April 12, 2018, 2:52am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/12 "2018-04-12T02:52:11Z")

</div>

Thanks guys. I have solved my problem.  
Marked @arivu96’s reply as the solution as his screenshot is the clearest/easiest to understand.

Note that the Move method requires that the destination directory(second parameter) to not exist.  
The method works like this: it will first create a folder in the specified destination parameter, and the contents from source folder will be moved to that folder.

Thanks everyone. appreciate the help 🙂

---

<div class="post-metadata">

**Author:** ![cclam81](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/cclam81/32/188418_2.png) [@cclam81](https://forum.uipath.com/u/cclam81)\
**Post date:** [June 19, 2018, 2:25am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/13 "2018-06-19T02:25:15Z")

</div>

Hi @arivu96, is there a way to move folders/files using the Invoke method across different volumes/root folders?

I got the below exception as I am trying to move a folder from my desktop to a shared drive.

Message: Source and destination path must have identical roots. Move will not work across volumes.

---

<div class="post-metadata">

**Author:** ![cclam81](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/cclam81/32/188418_2.png) [@cclam81](https://forum.uipath.com/u/cclam81)\
**Post date:** [June 19, 2018, 3:05am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/14 "2018-06-19T03:05:28Z")

</div>

I found the solution via another post.  
Just use this in the Invoke method:  
TargetType: Microsoft.VisualBasic.FileIo.FileSystem  
MethodName: MoveDirectory

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [October 29, 2018, 9:19am UTC](https://forum.uipath.com/t/move-delete-a-directory-folder/28583/15 "2018-10-29T09:19:18Z")

</div>

Closed on October 29, 2018, 9:19am UTC


