Javascript FileSystemObject (FSO) GetExtensionName method provides the functionality to retrieve the extension of the specified file in the path. GetExtensionName method extracts the name of the extension that exists after the “.” symbol with file name. If path specified in the FSO GetExtensionName method does not contain any file name then it returns the empty string.
Syntax for Javascript FSO GetExtensionName method
fso.GetExtensionName( Path );
As shown in the above syntax of FSO GetExtensionName method it accepts only one parameter as path of the file whose extension is to be retrieved.
Example of FSO GetExtensionName method
<script type="text/javascript">
// initialize ActiveXObject and create an object of Scripting.FileSystemObject.
var fso = new ActiveXObject("Scripting.FileSystemObject");
// returns the file extension from the specified path
var fileExt = fso.GetExtensionName("c:\\Temp\\myFolder\\file.txt");
document.write(fileExt);
document.write("<br />");
fso = null;
// Output:
// txt
</script>
Continue to next tutorial: Javascript FSO GetFile Method to learn how get the file information.