Hi,
I have a function to check if a file is open:
Public Shared Function IsFileOpen(ByVal fileItem As String, ByRef bFileStatus As Boolean) As Boolean
Try
Dim stream As FileStream = System.IO.File.OpenRead(fileItem)
stream.Close()
bFileStatus = False
Catch
bFileStatus = True
End Try
Return bFileStatus
End Function
I need to check whether a file is open so that an alert can be put on screen for the user to close it before continuing to the next stage of the application.
But when I test the function with a file open, the error is not being caught.
Can anyone help please?
I have a function to check if a file is open:
Public Shared Function IsFileOpen(ByVal fileItem As String, ByRef bFileStatus As Boolean) As Boolean
Try
Dim stream As FileStream = System.IO.File.OpenRead(fileItem)
stream.Close()
bFileStatus = False
Catch
bFileStatus = True
End Try
Return bFileStatus
End Function
I need to check whether a file is open so that an alert can be put on screen for the user to close it before continuing to the next stage of the application.
But when I test the function with a file open, the error is not being caught.
Can anyone help please?