Javascript GetParentFolderName method of FileSystemObject (FSO) provides the functionality to get the name of the folder of specified file in the provided path. GetParentFolderName method returns the folder name in which the specified file exists that is being represented by the specified path of the file. So, we can say that FSO GetParentFolderName method returns the complete path along with name of the folder that occurs nearest to the file name provided in the specified location path.
Syntax for Javascript FSO GetParentFolderName Method
fso.GetParentFolderName( path );
GetParentFolderName method accepts only one parameter as path for file whose parent folder name is to be retrieved.
Example of FSO GetParentFolderName Method
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// returns the parent folder name from the specified path
var pfName = fso.GetParentFolderName("c:\\Temp\\myFolder\\file.txt");
document.write(pfName);
document.write("<br />");
fso = null;
// Output:
// c:\Temp\myFolder
</script>
Continue to next tutorial: Javascript FSO GetSpecialFolder Method to learn how to get the special folders of windows OS.