MS_21.01.2016
This commit is contained in:
@@ -27,4 +27,27 @@ Public Class ClassHelper
|
||||
End If
|
||||
Return tempName
|
||||
End Function
|
||||
Public Shared Function CheckFileIsInUse(ByVal filename) As Boolean
|
||||
Dim fs As Integer = FreeFile()
|
||||
Dim inuse As Boolean = False
|
||||
If File.Exists(filename) Then
|
||||
Try
|
||||
Using f As New IO.FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.None)
|
||||
' thisFileInUse = False
|
||||
End Using
|
||||
Catch
|
||||
inuse = True
|
||||
End Try
|
||||
|
||||
Try
|
||||
FileOpen(fs, filename, OpenMode.Binary, OpenAccess.ReadWrite, OpenShare.LockReadWrite)
|
||||
Catch ex As Exception
|
||||
ClassLogger.Add("File " & filename & " inuse or not able to open - message: " & ex.Message, True)
|
||||
inuse = True
|
||||
Finally
|
||||
FileClose(fs)
|
||||
End Try
|
||||
End If
|
||||
Return inuse
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user