I have an update program that is completely independent of my main application. I run the update.exe to update the app.exe. To check to see if the file is in use, I move it
This is what I ended up doing. The network scan did not work on a peer-to-peer network. It didn't resolve the other computers at all.
Anyhow, here it is:
Private Sub CheckFileIfFileIsInUse(ByVal thefilename As String)
Try
' on the Vista OS you can rename a file that is in use
' the 'in use' of the original file follows the new file nameDim testfile As String = thefilename & ".tst"
If IO.File.Exists(testfile) Then
IO.File.Delete(testfile)
End If
' so we have to rename it to something else
IO.File.Move(thefilename, testfile)
' copy it back to the original file name in case something
breaks ' this just keeps them in working order if it does
IO.File.Copy(testfile, thefilename)
' then we try to delete the original file that could be in use
' which will return an 'in use' error at this point
If IO.File.Exists(testfile) Then
IO.File.Delete(testfile)
End If
Catch ex As Exception
'throw it to the originating method
Throw
End Try
End Sub
Hope this helps the next person.