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. Path property returns the complete path of the specified file or folder. 

Syntax for FSO Path Property

fileObj.Path

// or
folderObj.Path

You can use any of the above syntax code to access the Path of the file or folder. If you will use the folder object then it will return the path of the specified folder and if you will use the file object then Path property will return the complete path of the specified file along with file name and its extension. GetFile method provides the file object and GetFolder method provides the folder object to access the Path property.

Example 1

File object to get the value of Path 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>File Path : </b>" + fileObj.Path);
    document.write("<br />");

    // Output: 
    // File Path : C:\Temp\textFile.txt
</script>

Example 2

Folder object to get the value of Path 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>Folder Path : </b>" + folderObj.Path);
    document.write("<br />");

    // Output: 
    // Folder Path : C:\Temp\myFolder
</script>

Continue to next tutorial: Javascript FSO ShortName property to learn how to get the short name of the speicified file or object according to 8.3 namaing conventions.

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.