# Workspace-rule for removing a directory

**URL:** https://www.finalbuilder.com/forums/t/workspace-rule-for-removing-a-directory/5530
**Category:** Discussion
**Created:** [November 25, 2016, 6:19am UTC](https://www.finalbuilder.com/forums/t/workspace-rule-for-removing-a-directory/5530 "2016-11-25T06:19:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rynardald](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/r/a88e57/32.png) [@rynardald](https://www.finalbuilder.com/forums/u/rynardald)
#### Post date: [November 25, 2016, 6:19am UTC](https://www.finalbuilder.com/forums/t/workspace-rule-for-removing-a-directory/5530/1 "2016-11-25T06:19:30Z")

</div>

Hi,  
what is the right workspace-rule for deleting a directory on the server-workspace?

- "/Dir\_to\_delete/ \<\< /InvalidDirName"

or

- "/Dir\_to\_delete/ \<\< /"

or none of them?  
  
Both are working but I don't know whate side-effects they can have.

---

<div class="post-metadata">

### Author: ![rynardald](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/r/a88e57/32.png) [@rynardald](https://www.finalbuilder.com/forums/u/rynardald)
#### Post date: [November 25, 2016, 6:31am UTC](https://www.finalbuilder.com/forums/t/workspace-rule-for-removing-a-directory/5530/2 "2016-11-25T06:31:40Z")

</div>

Sorry, correction.   
 None of them worked. Both removed the directory but both raised in “Agent To Server Workspace Sync” a exception “An error occurred while syncing files from the server to the agent. Details: Exception: NullReferenceException”.   
  
 Is there a other rule with which I can remove directories?

---

<div class="post-metadata">

### Author: ![Sparky](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/sparky/32/10_2.png) [@Sparky](https://www.finalbuilder.com/forums/u/Sparky)
#### Post date: [November 29, 2016, 1:40am UTC](https://www.finalbuilder.com/forums/t/workspace-rule-for-removing-a-directory/5530/3 "2016-11-29T01:40:38Z")

</div>

Hi Rynardald,  
  
There isn’t a rule especially for deleting workspace folders. The \<\< rule operator deletes the destination folder before copying the files from the source folder. &nbsp;  
  
In our tests, the second rule does indeed raise a NullReferenceException exception. There will be a fix for this in the next version.  
  
However, the first rule has the desired effect in our tests.  
  
/Dir\_to\_delete/ \<\< /InvalidDirName  
  
removes Dir\_to\_delete as required. If this is not working for you, can you send the build log for this rule to [support@finalbuilder.com](mailto:support@finalbuilder.com). Turn on the “Log workspace files copies” option in each stage before running the build so we can see what is happening in the log.  
  
In the mean time, you may be able to get this working by changing the rule to:  
  
/Dir\_to\_delete/ \<\< /InvalidDirName\*\*
