Javascript FileSystemObject Drive AvailableSpace property

Updated on 30 Mar 2012,
Published on 26 Sep 2008

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

Example of Javascript Drive Object AvailableSpace 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");

    // get Available Space on specified drive and convert the value in bytes to giga bytes
    var freeSpace = (driveObj.AvailableSpace) / (1024 * 1024 * 1024);

    document.write("<b>Available Space :</b> " + freeSpace + " GB");

    // Output: 
    // Available Space : 9.887771606445312 GB
</script>

Continue to next tutorial: Javascript FSO Drive Object DriveLetter property to learn how to get the drive letter of the specified drive.

0 Responses to "Javascript FileSystemObject Drive AvailableSpace property"
Leave a Comment
* required
* required
* will not be published
* optional
* hint: http://www.example.com
  • Subscribe via Email
  • HIRE EzineASP.Net Developers