How to get folder "size on disk" value?

Tommyknocker

Member
Joined
Jul 27, 2009
Messages
5
Programming Experience
Beginner
Hello,

I need to find out how to get the "size on disk" value for some folders.
Getting the "size" is not a problem but in this case, this folder has the "compress content to save disk space" enabled.
This "size on disk" is really important to find as some folders on the disk have quotas and checking only on the "normal" size gives some values that are exceeding the quota.
i.e. quota is 45 MB. Folder size is 47 MB. Folder "size on disk" is 38 MB.
Based on the first "size", no more file can be added. Based on the second one, not true.
Can someone help me on this? Would it be possible to get a piece of code?
Many thanks in advance.
 
From Help:

VB.NET:
' The following example displays the names and sizes
' of the files in the specified directory.
Imports System
Imports System.IO

Public Class FileLength

    Public Shared Sub Main()
        ' Make a reference to a directory.
        Dim di As New DirectoryInfo("c:\")
        ' Get a reference to each file in that directory.
        Dim fiArr As FileInfo() = di.GetFiles()
        ' Display the names and sizes of the files.
        Dim f As FileInfo
        Console.WriteLine("The directory {0} contains the following files:", di.Name)
        For Each f In fiArr
            Console.WriteLine("The size of {0} is {1} bytes.", f.Name, f.Length)
        Next f
    End Sub 'Main
End Class 'FileLength
 
Yup. I thought of suggesting that, but thought it might not give the actual 'size-on-disk' as requested whereas I am pretty sure that the WMI method does. Who knows?
 
Thanks to all but sorry, none of the solution works.
The WMI just returns the "normal" size, not the "size on disk".
I think I need to use the "GetCompressedFileSize", but not sure.
If anybody has an idea, he's more than welcome.
Thanks in advance.
 
Back
Top