In Javascript, Drive object returned by the GetDrive method of FileSystemObject provides the access to TotalSize property. The TotalSize property of Drive object returns the information about the amount of total disk space i.e. free plus used disk space on the specified drive or network shared drive. Javascript Drive object’s TotalSize property returns the number of bytes as total space on the specified drive that can be utilized by the user to store data. 

Example of Javascript Drive Object TotalSize property

<script type="text/javascript">
    // initialize ActiveXObject and create an object of Scripting.FileSystemObject.
    var fso = new ActiveXObject("Scripting.FileSystemObject");

    // Drive object reference set to driveObj variable
    var driveObj = fso.GetDrive("C");

    // returns total size of the specified drive. You can convert the value in bytes to giga bytes
    var totalSize = (driveObj.TotalSize) / (1024 * 1024 * 1024);
    document.write("<b>Total Space :</b> " + totalSize + " GB");

    document.write("<br />");

    totalSize = (fso.GetDrive("\\\\my-PC\\E").TotalSize) / (1024 * 1024 * 1024);

    document.write("<b>Total Space :</b> " + totalSize + " GB");

    // Output: 
    // Total Space : 15.62716293334961 GB 
    // Total Space : 19.524398803710937 GB
</script>

Continue to next tutorial: Javascript FSO Drive Object VolumeName property to learn how to get the disk label of the specified drive.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.