clean up
This commit is contained in:
@@ -75,6 +75,11 @@ Public Class File
|
||||
Return oCleanName
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Reads the file at `FilePath` and computes a SHA256 Hash from its contents
|
||||
''' </summary>
|
||||
''' <param name="FilePath"></param>
|
||||
''' <returns></returns>
|
||||
Public Function GetChecksum(FilePath As String) As String
|
||||
Try
|
||||
Using oFileStream = IO.File.OpenRead(FilePath)
|
||||
@@ -339,6 +344,24 @@ Public Class File
|
||||
End Try
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Checks if a file is locked, ie. in use by another process.
|
||||
''' </summary>
|
||||
''' <remarks>
|
||||
''' https://docs.microsoft.com/en-us/dotnet/standard/io/handling-io-errors
|
||||
''' </remarks>
|
||||
Public Function TestFileIsLocked(pFilePath As String) As Boolean
|
||||
Try
|
||||
Using stream As FileStream = IO.File.Open(FileMode.Open, FileAccess.Read, FileShare.None)
|
||||
stream.Close()
|
||||
End Using
|
||||
Catch ex As Exception When ((ex.HResult And &HFFFF) = 32)
|
||||
Return True
|
||||
End Try
|
||||
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Public Function TestPathIsDirectory(Path As String) As Boolean
|
||||
If Not Directory.Exists(Path) Then
|
||||
Return False
|
||||
|
||||
Reference in New Issue
Block a user