Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


DirSize Function

Keywords: 	 dirsize

Question:

Is there a call or clever bit of programming that will return the total size of a directory tree?

Answer:

In the new 98 version, the DirSize function will do this (look in the help file). Otherwise download the "File Searcher" extender and use that to write a dir size calculator. Space taken depends on cluster size and whether the file is on a compressed volume or not. The function is asking the OS what the cluster size is. The results from DiskInfo give too large a cluster size for the Fat32 drive. 32768 for a little 3 GB drive; accurate for Fat16.

Here's some information on the DirSize(1) anomalies:

  1. There is a documented MS bug in that Windows 95 will return the incorrect information for hard drives bigger than 2GB.

  2. See what the code below returns. Compare it to what you expect.
    	Disk="C"
    	spc = DiskInfo(disk, 1)
    	bps = DiskInfo(disk, 2)
    	bpc = spc * bps
    	Message("Cluster size on drive C:", bpc)
    
    You'll notice that the results from DiskInfo give too large a cluster size for the Fat32 drive. 32768 for a little 3 GB drive; accurate for Fat16.
Depending on the exact conversion you want you may have to convert the DirSize return value to MB.
MB1=a / (1000*1000)
MB2=a / (1000*1024)
MB3=a / (1024*1024)

answers=strcat("MB1=",mb1,@crlf,"MB2=",mb2,@crlf,mb3)

Message("Answers",answers)

Article ID:   W13051
Filename:   DirSize Function Anomalies.txt