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.