diff --git a/Filesystem/File.vb b/Filesystem/File.vb index 3a20856d..a053c798 100644 --- a/Filesystem/File.vb +++ b/Filesystem/File.vb @@ -404,6 +404,34 @@ Public Class File Return oIsDirectory End Function + ''' + ''' Checks the size of the supplied file. + ''' + ''' + ''' + ''' + 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)