Javascript contains ActiveXObject function that provides the functionality to create FileSystemObject. Javascript Scripting FileSystemObject further provides its client side properties and functions that we discussed in the previous tutorial about JavaScript FileSystemObject. In this tutorial we will learn how to create FileSystemObject using ActiveXObject function of JavaScript. But remember that ActiveXObject method of Javascript could create activeX based objects on the client side i.e. client’s PC if Automation server of their browser allows to create objects otherwise it will throw an exception: “Automation server can’t create object.” As you know JavaScript works at client side therefore while using FileSystemObject you are totally dependent on the security level of web browser of the client’s machine.
JavaScript ActiveXObject Scripting FileSystemObject
<script type="text/javascript" language="javascript">
var fso = new ActiveXObject("Scripting.FileSystemObject");
</script>
In the above javascript code “new” keyword has been used to initialize the ActiveXObject. “Scripting.FileSystemObject“ string passed to the ActiveXObject function of javascript creates the file system object that allows the access of file system of client’s machine. If the Javascript Automation Server of client’s system allows creating the activeX object related to FSO then object created for FSO will allow you to perform all the functions provided by it. To access the supported functions and properties of Javascript Scripting FileSystemObject use the dot operator in the code e.g.: fso.Drives, fso.BuildPath.
Continue to next tutorial: Javascript FileSystemObject Drives Property to learn how to get the list of drives on client’s PC.