Rename folder and Copy files always meet locking issue



I have an activity that for each mail I received, I tried to create a temp folder using [Create Directory] activity and move the files in this temp folder to a named directory using [For each][Move Files].
The problem is that I cannot move the files because of this error :
Move file : The process cannot access the file because it is being used by another process.
I tried used powershell method but also meet similar locking problem.
“Rename-Item -Path " + varMailSaveFolder +” -NewName " + varMailSaveFolder + "" + varClientID_

Is there any best practices about rename / move folder or files that won’t have files or folder locking issue ? If I loop to a batch of folder/files , it is so easy to meet such locking issue.



Found it is my problem that the previous customed .net script locked files. Thanks All.