Public Function analyzeTotalFilesSize(Path) As Integer
        Dim lookInDirectory As New DirectoryInfo(Path)

        For Each Directory As DirectoryInfo In lookInDirectory.GetDirectories

        For Each File As FileInfo In lookInDirectory.GetFiles
            If _ListOfFiles.Exists(Function(x) x.ToString = File.Extension.ToLower) Then
                _SizeOfFilesToCopy += File.Length / 1024
            End If

        If _SizeOfFilesToCopy < 1024 Then
            errorhere -------->> Return _SizeOfFilesToCopy.ToString("#,##0.00") & "KB"
        ElseIf _SizeOfFilesToCopy > 1024 And _SizeOfFilesToCopy < 1048576 Then
            Return (_SizeOfFilesToCopy / 2014).ToString("#,##0.00") & "MB"
            Return (_SizeOfFilesToCopy / 1048576).ToString("#,##0.00") & "GB"
        End If
    End Function

i got this error and cant find out why it's 0.00kb when it should have value
'Conversion from string "0.00KB" to type 'Integer' is not valid.

You declared the function as Integer but you returning a string.
Change the function return type to String: Public Function analyzeTotalFilesSize(Path) As String

This question has already been answered. Start a new discussion instead.