CSplitpath:GetFilenameExt


The GetFilenameExt method returns the filename+extension from a CSplitpath object. The returned string has a form like "filename.ext". If the filename has no extension, it is returned without a terminating period.

Syntax

sNameExt = CSplitpath:GetFilenameExt()

where

 

    sNameExt is a string containing the file name and ectension. On failure, nil is returned.

Example

Suppose a file exists with a full path named sPath. The following script retrieves the filename and extension components:

S = CSplitpath:new( sPath )

-- create a CSplitpath object for path sPath

sNameExt = S:GetFilenameExt()

-- returns the filename and extension

S:delete()

-- when done with S, remove it from memory

Related Topics

CSplitpath class