Javascript FileSystemObject GetDrive method with Properties

Updated on 26 Mar 2012,
Published on 26 Sep 2008

Javascript FileSystemObject provides GetDrive method that accepts drive specification or UNC (Universal Naming Convention) shared name. GetDrive method provided by FileSystemObject further allows the access to various properties associated with different types of drives associated with computers. All the properties supported by the GetDrive method work according to the specified type of drive whether it is fixed Hard Disk drive, CD Drive, DVD Drive or Floppy drive. Javascript FileSystemObject GetDrive method returns a drive object and provides the support to the selective properties of Drive object. With the use of properties of GetDrive method’s returned object you can access the information about specified Drive for example its total size, available size, volume label etc.

Syntax for JavaScript FileSystemObject GetDrive Method

fso.GetDrive( Drive Specification );

GetDrive method of FileSystemObject accepts 1 parameter as drive specification or UNC shared name of drive and returns the Drive object. Further Drive object returned by the GetDrive function provides the access to various properties associated with memory Drives of computer system of client.

Example of Javascript FileSystemObject GetDrive Method

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

    var driveObj = fso.GetDrive("C"); 
</script>

You can pass the drive letter specification or UNC share name to the GetDrive function e.g.: "C" or "\\my-computer\c"

Properties of Javascript FileSystemObject GetDrive Method

Following are the properties of Drive object returned by GetDrive method:

  1. AvailableSpace: returns the available free space on the specified drive.
  2. DriveLetter: returns the uppercase drive letter of associated with specified local drive or network share.
  3. DriveType: returns the type of specified drive whether it is fixed hard disk, CD drive etc. 
  4. FileSystem: returns the file system of specified drive.
  5. FreeSpace: returns the amount of free space available on the specified drive or network share.
  6. IsReady: returns Boolean value i.e. true or false based on the state of specified drive. It checks whether the drive is ready to use or not.
  7. Path: returns the uppercase drive letter followed by colon that specifies the path name for the drive.
  8. RootFolder: returns the folder object representing the root folder of specified drive or network share.
  9. SerialNumber: returns the serial number of the specified drive.
  10. ShareName: returns the network shared name of the specified UNC share.
  11. TotalSize: returns the total size of the specified drive.
  12. VolumeName: returns the drive volume label of the specified drive.

Continue to next tutorial: Javascript FSO GetDriveName Method to learn how to get the drive letter from the specified path.

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