Javascript FileSystemObject (FSO) GetSpecialFolder method also provides the functionality to access the properties and methods associated with folder object. GetSpecialFolder method returns the path of any of the 3 special folders of windows based on the parameter value specified to it. FSO GetSpecialFolder method returns the Folder object that further provides the access to all such properties and methods. GetSpecialFolder method allows you to access the properties such as Name, Date last accessed, date last modified, path, parent folder etc. Methods supported by GetSpecialFolder method are copy, move, delete, create text file and retrieve its text stream to write text into it, is root folder etc. This method targets the specified special folder and performs each action on it based on the applied method. 

Syntax for Javascript FSO GetSpecialFolder Method

fso.GetSpecialFolder( SpecialFolder );

As shown in the above syntax FSO GetSpecialFolder method accepts only 1 parameter as SpecialFolder that specifies the windows’ folder to be accessed at client side. Following are the supported value types of SpecialFolder parameter:

0 = WindowsFolder

1 = SystemFolder

2 = TemporaryFolder

Example of FSO GetSpecialFolder Method

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

    // returns the folder object associated with the specified special folder
    // 0 = windows folder
    var folderObj = fso.GetSpecialFolder(0);
    document.write(folderObj.Path);
    document.write("<br />");

    // 1 = System32 folder of windows
    folderObj = fso.GetSpecialFolder(1);
    document.write(folderObj.Path);
    document.write("<br />");

    // 2 = temporary folder of windows
    folderObj = fso.GetSpecialFolder(2);
    document.write(folderObj.Path);

    fso = null;

    // Output: 
    // C:\WINDOWS 
    // C:\WINDOWS\system32 
    // C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp
</script>

Continue to next tutorial: Javascript FSO GetTempName Method to learn how to get the name of the temporary file to store the temporary data.

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.