I have a problem with automating a deployment, after I stop the service there is still a lock on the file and I am unable to delete it. I really do not want to start hacking about with sleeps to make something that 'usually works'. Is there a good way to properly resolve the problem of locked files, perhaps some kind of 'wait until file is removable':
Get-ChildItem : Access to the path 'D:MyDirectory' is denied.
'Test-Path' is not sufficient in this case as the folder both exists and I have access to it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…