Javascript FSO Drive Object FreeSpace 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 FreeSpace property. The FreeSpace 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 FreeSpace property returns the number of bytes as free space available on the specified drive that can be utilized by the user to store more data. 

Example of Javascript Drive Object FreeSpace 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 Free Space on specified drive and convert the value in bytes to giga bytes
    var freeSpace = (driveObj.FreeSpace) / (1024 * 1024 * 1024);

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

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

Continue to next tutorial: Javascript FSO Drive Object IsReady property to learn how to check the ready state of removable drive.

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