Filesystem: Add TestFileSizeIsLessThanMaxFileSize
This commit is contained in:
parent
4ee519d8c6
commit
41bba8b214
@ -404,6 +404,34 @@ Public Class File
|
||||
Return oIsDirectory
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Checks the size of the supplied file.
|
||||
''' </summary>
|
||||
''' <param name="pFilePath"></param>
|
||||
''' <param name="pMaxFileSizeInMegaBytes"></param>
|
||||
''' <returns></returns>
|
||||
Public Function TestFileSizeIsLessThanMaxFileSize(pFilePath As String, pMaxFileSizeInMegabytes As Integer)
|
||||
Dim oFileInfo As New FileInfo(pFilePath)
|
||||
|
||||
_Logger.Info("Checking Filesize of {0}", oFileInfo.Name)
|
||||
_Logger.Debug("Filesize threshold is {0} MB.", pMaxFileSizeInMegabytes)
|
||||
|
||||
If pMaxFileSizeInMegabytes <= 0 Then
|
||||
_Logger.Debug("Filesize is not configured. Skipping check.")
|
||||
Return True
|
||||
End If
|
||||
|
||||
Dim oMaxSize = pMaxFileSizeInMegabytes * 1024 * 1024
|
||||
|
||||
If oMaxSize > 0 And oFileInfo.Length > oMaxSize Then
|
||||
_Logger.Debug("Filesize is bigger than threshold.")
|
||||
Return False
|
||||
Else
|
||||
_Logger.Debug("Filesize is smaller than threshold. All fine.")
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function GetDateDirectory(pBaseDirectory As String, pDate As Date) As String
|
||||
Dim oDateDirectory = GetDateString(pDate)
|
||||
Dim oFinalDirectory As String = IO.Path.Combine(pBaseDirectory, oDateDirectory)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user