Want to stop a file "being used". how to use "Dispose" in UiPath?

Hi guys,

I have a fairly complex automation that is collecting PDF files and merging them, and performing other similar operations. I am running this on a VM
I constantly find I cannot edit, save, move or delete a file because it is apparently “open” in uipath, even when the last activity has finished with it.

In a previous automation I used the “dispose” functon via Invoke Method to correctly close email attachments so they were no longer “being used by another process”. How do I implement this with other files and objects?