jj: test if path is directory

This commit is contained in:
Jonathan Jenne 2018-10-12 16:17:34 +02:00
parent f939e0760c
commit 73a5f34587

View File

@ -39,13 +39,16 @@ Public Class File
''' <param name="ContinueOnError">Should the function continue with deleting when a file could not be deleted?</param>
''' <returns>True if all files were deleted or if no files were deleted, otherwise false</returns>
Public Function RemoveFiles(Path As String, FileKeepTime As Integer, FileBaseName As String, Optional FileExtension As String = "log", Optional ContinueOnError As Boolean = True) As Boolean
If Not TestPathIsDirectory(Path) Then
Throw New ArgumentException($"Path {Path} is not a directory!")
End If
If Not Directory.Exists(Path) Then
_logger.Warn("Directory {0} does not exist")
Return False
Throw New DirectoryNotFoundException($"Path {Path} does not exist!")
End If
If FileKeepTime < 0 Or FileKeepTime > 1000 Then
Throw New ArgumentOutOfRangeException("FileKeepTime must be an integer between 0 and 1000")
Throw New ArgumentOutOfRangeException("FileKeepTime must be an integer between 0 and 1000!")
End If
Dim oUnableToDeleteCounter = 0
@ -85,4 +88,10 @@ Public Class File
Return True
End Function
Private Function TestPathIsDirectory(Path As String) As Boolean
Dim oIsDirectory As Boolean = (System.IO.File.GetAttributes(Path) And FileAttributes.Directory) = FileAttributes.Directory
Return oIsDirectory
End Function
End Class