Javascript FSO Drive Object Path property

Updated on 30 Mar 2012,
Published on 27 Sep 2008

In Javascript, Drive object returned by the GetDrive method of FileSystemObject (FSO) provides the access to Path property. This Path property of Drive object returns the uppercase Letter followed by colon symbol ":" that represents the specified drive. You can identify the drive of the client’s PC through this Path property of Drive object. GetDrive method accepts the English alphabet representing drives of computer system for example A, C, D or E according to the number of drives found on client’s PC whose Path you want to retrieve. Path property returns the UNC shared name of the drive for the specified shared network drive. 

Example of Javascript Drive Object Path 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 the drive letter in uppercase with colon at its end
    document.write("<b>Drive base Path :</b> " + driveObj.Path);

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

    document.write("<b>Drive base Path :</b> " 
                    + fso.GetDrive("\\\\my-PC\\E").Path);

    // Output: 
    // Drive base Path : C: 
    // Drive base Path : \\my-PC\E
</script>

Continue to next tutorial: Javascript FSO Drive Object RootFolder property to learn how to get the root path of the specified drive.

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