我有一个PS脚本,每5分钟启动一次,检查新删除的文件夹并移动它们.问题是有时文件夹中的项目仍在写入,在这种情况下脚本错误:
Move-Item:进程无法访问该文件,因为它正由另一个进程使用.[Move-Item],IOException + FullyQualifiedErrorId:MoveDirectoryItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand
我尝试了以下try/catch块,但它仍然在同一个"Move-Item"行上出错.对我在这里做错了什么的想法?
try {
Move-Item -Force "$fileString" $fileStringFixed
}
catch [System.IO.IOException] {
return
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
powershell ×1