Javascript FSO Drive Property
Javascript FileSystemObject (FSO) provides a Drive property that can be accessed through file object or folder object returned by the GetFile method or GetFolder methods. Both these methods allow the access to Drive property that returns the drive specification letter on which the specified file or folder resides.
Syntax for FSO Drive Property
fileObj.Drive // or folderObj.Drive
Both above syntaxes show the way of using the file object and folder object to access the Drive property. GetFile method returns the file object and GetFolder method returns the folder object that can be used to access the Drive property associated with the specified file or folder. In simple words you can say that Drive property returns the Drive letter with colon ":" symbol at end on which the specified file or folder resides.
Example 1
File object to get the value of Drive property
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// object created for file object returned by GetFile method
var fileObj = fso.GetFile("C:\\Temp\\textFile.txt");
document.write("<b>Drive specification: </b>" + fileObj.Drive);
document.write("<br />");
// Output:
// Drive specification: C:
</script>
Example 2
Folder object to get the value of Drive property
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// object created for folder object returned by GetFolder method
var folderObj = fso.GetFolder("C:\\Temp\\myFolder");
document.write("<b>Drive specification: </b>" + folderObj.Drive);
document.write("<br />");
// Output:
// Drive specification: C:
</script>
Continue to next tutorial: Javascript FSO Name Property to learn how to get the name of the specified file or folder.

* will not be published
* hint: http://www.example.com