FileSystemObject : GetExtensionName Method


Returns extension of a file, return empty string if file doesn’t exist.

Format : 

objectOfFileSystemObject. GetExtensionName(filepath)

  • objectOfFileSystemObject : As the names says, it’s a FileSystemObject.
    • filepath
      • Mandatory
      • Type:     String
      • filepath , whose extension to be return.

Function FnGetExtensionName (strFilePath)
      Set fso = CreateObject("Scripting.FileSystemObject")
      strFileExtension = fso. GetExtensionName (strFilePath)      
      FnGetExtensionName = strFileExtension
End Function

Msgbox FnGetExtensionName (“c:\NewFolder\file.txt”)



Leave a Comment