Question
· Dec 17, 2023

Getting free disk Space

Hi Guys,

How to get free disk space, I found that I could use GetDirectorySpace but not sure how to use it in getting free space in my D drive?

 

 

Thank 

Product version: Ensemble 2018.1
Discussion (2)2
Log in or sign up to continue

Set sc=##class(%File).GetDirectorySpace("D:",.FreeSpace)

Write FreeSpace

Classreference:

classmethod GetDirectorySpace(Name As %String, ByRef FreeSpace As %String, ByRef TotalSpace As %String, Flag As %Integer = 1) as %Status
Return the amount of total space and free space in either Bytes,MB,GB on a drive or directory
Name = Valid Drive or directory specification
Flag = 0 - Return bytes
Flag = 1 - Return MB (Default)
Flag = 2 - Return GB

MB and GB returned are rounded to 2 decimal places.
Any error status returned is O/S level error. Note that on Windows only drives have a measurement for free space and directories can not so the FreeSpace is only returned for drives.