GetExtensionName Method


Returns the extension (for example "txt" or "exe") of the last component in a path.




  • object
    Required. Always the name of a FileSystemObject.

  • path
    Required. The path of the component whose extension is to be returned.


For network drives, the root directory (\) is considered to be a component.

This method returns an empty string ("") if the file doe not exist.

The following example illustrates the use of the GetExtensionName method.

Function GetAnExtension(DriveSpec)
   Dim fso
   Set fso = CreateObject("Scripting.FileSystemObject")
   GetAnExtension = fso.GetExtensionName(Drivespec)
End Function

Applies To:

FileSystemObject Object