Is this the best way to handle file moving in a windows service? we have many files that get matched and moved, but an end user may have the file opened at the time of moving.
This is what the code currently says:
Do While IO.File.Exists(OriginalFilePath)
Try
IO.File.Move(OriginalFilePath, BestMatchPath)
Catch ex As IO.IOException
Log(TraceLevel.Warning, "The file '{0}' was unable to be moved (probably opened by someone)", OriginalFilePath)
Threading.Thread.Sleep(1000)
End Try
Loop
Is there a better way to manage this? I have thought of threading it to allow the process to continue, but currently i am unsure if this is viable, as the rest of the process might need the files path to be accurate.