GetFileExtension

Returns the part of a path from its last period, the period included.

Syntax: object.GetFileExtension ( strFullPath ) As String

object
required An object expression that evaluates to a cDialog.
strFullPath
required A String, a path or a file name.

Remarks

GetFileExtension returns the extension with its period: .txt for C:\Docs\summary.txt. A string with no period gives an empty string. Of archive.tar.gz only .gz is returned, and a name that ends with a period gives ..

Note

The method searches the whole string for the last period, not the file name only. A period in a folder name is taken for the start of an extension when the file name has none: C:\my.dir\notes gives .dir\notes. GetFileNameWithoutExt looks in the file name only, and gives notes for the same path.

The method works on text only. It does not check that the file exists, and it reads no property of the object.

Example

Dim dlg As New cDialog
Debug.Print dlg.GetFileExtension("C:\Docs\summary.txt")   ' .txt
Debug.Print dlg.GetFileExtension("archive.tar.gz")        ' .gz
Debug.Print dlg.GetFileExtension("report.")               ' .
Debug.Print "[" & dlg.GetFileExtension("README") & "]"    ' []
Debug.Print dlg.GetFileExtension("C:\my.dir\notes")       ' .dir\notes

See Also