^^^ That answer is in C#! I am using VB.NET! ^^^
I am using a FileSystemWatcher to monitor a folder for new files.
This sub gets triggered when it detects a change, which should then copy the file to the server.
Private Sub OnCreated(source As Object, e As FileSystemEventArgs)
Dim LocalFile As String = e.FullPath
Dim ServerFile As String = LocalFile.Replace(localSyncPath, serverSyncPath)
Try
File.Copy(LocalFile, ServerFile)
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Problem is that this usually pops up an error to say the file is in use. Is there a way to run a loop to keep trying until it works? Or even copy dispite being in use?