Exception calling "Resolve" with "2" argument(s): "File not found"
I'm using some code based on the "Synchronization" PowerShell code found here:
Automating transfers or synchronization in parallel connections over SFTP/FTP protocol
The code works perfectly under most situations. However, I'm having one issue. If the file is open/locked/in-use, the thread will skip/continue as expected, but then return an error and crash/abort/exit.
Any ideas?
I believe this is the relevant section of code from the logs, but I'll can attach them if need be.
Additional data:
* The
I *think* I may have found a workaround by wrapping the
Here's what I'm doing to try and get around the issue:
Automating transfers or synchronization in parallel connections over SFTP/FTP protocol
The code works perfectly under most situations. However, I'm having one issue. If the file is open/locked/in-use, the thread will skip/continue as expected, but then return an error and crash/abort/exit.
Any ideas?
I believe this is the relevant section of code from the logs, but I'll can attach them if need be.
< 2024-12-05 18:12:06.315 The process cannot access the file because it is being used by another process . 2024-12-05 18:12:06.323 Answer: Skip * 2024-12-05 18:12:06.323 (ESkipFile) Can't open file 'C:\Users\<redeacted>\test\New Microsoft Excel Worksheet.xlsx'. * 2024-12-05 18:12:06.323 System Error. Code: 32. * 2024-12-05 18:12:06.323 The process cannot access the file because it is being used by another process . 2024-12-05 18:12:06.323 Copying finished: Transferred: 0, Elapsed: 0:00:00, CPS: 0/s . 2024-12-05 18:12:06.323 Session upkeep . 2024-12-05 18:12:06.323 Looking for network events . 2024-12-05 18:12:06.323 Timeout waiting for network events (ESkipFile) [1] Script Aborted Abnormally. (ESkipFile) [1] $difference.Resolve($syncSession, $transferOptions) # | Out-Null. > 2024-12-05 18:12:06.439 Script: exit
Additional Error Info: Error command : $difference.Resolve($syncSession, $transferOptions) # | Out-Null Error message : Exception calling "Resolve" with "2" argument(s): "File not found"
| Out-Null
isn't normally commented out, but it was for this debugging session in hopes of giving me more info to track down what's going on.
I *think* I may have found a workaround by wrapping the
Resolve
method in a try/catch loop, but would like to know if that more of a lame hack and if I'm just hiding the root cause that going to really bite me later. Suggestions?
Here's what I'm doing to try and get around the issue:
try { $difference.Resolve($syncSession, $transferOptions) | Out-Null } catch { }