CSplitpath:GetExt2 CSplitpath:GetFilenameExt

CSplitpath:GetFilename


The GetFilename method returns the filename from a CSplitpath object. The filename includes no directory or file extension.

Syntax

sFileName = CSplitpath:GetFilename()

    On success, this method returns a string containing the filename.

    On failure, this method returns nil.

Example

Suppose a file exists with a full path named sPath. The following script fragment retrieves the file name component:

 

S = CSplitpath:new()

-- create a CSplitpath object

S:SetPath(sPath)

-- Specify the path to be split

sFileName = S:GetFilename()

-- assigns the file name to sFileName.

S:delete()

-- when done with S, remove it from memory

Related Topics

CSplitpath