Javascript FileSystemObject (FSO) consists of DriveExists method that provides the functionality to check whether the specified drive exists at the given location or not. FSO DriveExists method returns the Boolean value i.e. true or false based on the existence of the specified drive. DriveExists method returns true if the drive exits and returns false if not. Javascript DriveExists method is very useful while creating or deleting the files or folders at client side coz if specified drive does not exist while mapping the path of the specified file or folder then it throws an error and stops the execution of rest of javascript code placed after that code line. 

Syntax for Javascript FSO DriveExists Method 

fso.DriveExists( driveSpec );

As shown above FSO DriveExists method accepts only one parameter as drive specification. It checks the specified drive and returns the Boolean value accordingly.

Example for FSO DriveExists Method

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

    // if condition to check whether the specified drive exists or not.
    if (fso.DriveExists("D")) {
        document.write("Drive D: exists.");
    }

    else {
        document.write("Drive D: does not exist.");
    }

    fso = null;
</script>

Continue to next tutorial: Javascript FSO FileExists Method to learn checking whether the specified file exists or not.

Recent JavaScript Tutorials

Javascript FSO ShortPath property

Javascript FileSystemObject (FSO) provides a ShortPath property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Path Property

Javascript FileSystemObject (FSO) provides the Path property that can be accessed through the file object or folder object returned by the GetFile or GelFolder method

Javascript FSO Type property

Javascript FileSystemObject (FSO) provides a Type property that can be accessed through file object or folder object returned by the GetFile or GetFolder method

Javascript FSO ShortName property

Javascript FileSystemObject (FSO) provides a ShortName property that can be accessed using the folder object or file object returned by the GetFolder or GetFile method.

Javascript FSO Name Property

Javascript FileSystemObject (FSO) provides a Name property that can be accessed using file object or folder object.