Name

FileSystemObject.GetExtensionName Method

Syntax

                  oFileSysObj.GetExtensionName(Path)
oFileSysObj

Use: Required

Data Subtype: FileSystemObject object

Any object variable returning a FileSystemObject object.

Path

Use: Required

Data Subtype: String

A path specifier.

Return Value

A Variant of subtype String.

Description

Returns the extension of the file element of a given path.

Rules at a Glance

If the extension in Path can’t be determined, a zero-length string (“”) is returned.

Programming Tips & Gotchas

  • GetExtensionName is a string parsing method rather than a filesystem method. It does not verify that Path is valid, does not verify that the filename designated in Path exists, and does not even guarantee that the value it returns is a valid file extension. In other words, GetExtensionName has no intelligence. It simply parses a string and returns the text that follows the last dot of the last element.

  • Path can be a network drive or share.

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.