Created
June 29, 2016 14:27
-
-
Save fredgdaley2/ce6424a37fe84a6a869438709fa5613c to your computer and use it in GitHub Desktop.
Wait for a file to be accessible if not wait 10 seconds and try again.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub WaitForFileToBeAccessible(ByVal fileWaitingOn As String) | |
Try | |
Using fs As FileStream = New FileStream(fileWaitingOn, FileMode.Open, FileAccess.ReadWrite, FileShare.None, 100) | |
fs.ReadByte() | |
End Using | |
Catch ex As Exception | |
System.Threading.Thread.Sleep(10000) | |
WaitForFileToBeAccessible(fileWaitingOn) | |
End Try | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment