Returning Filename from File Explorer Component

When using the file explorer component, is there a way to get the name of the selected file within the File Explorer component? I failed to see a property or method that would do this, I know that there is a selected path method, but I need just the filename.

EDIT: Further than returning just the filename, is it possible to return a select number of the directors, for example the first 3 folders or the last 3 folders?

EDIT: I developed a bit of code that would do this, but it is not optimal. I would have preferred that there be a dedicated API method. However if anyone else needs to know how to do this here is my code:

counter = 0 for counter in range(0, len(selectedPath)): selChar = selectedPath[(-counter - 1)] if selChar == '\\' or selChar == '/': filename = selectedPath[-counter:-4] print filename break
For now though, unless I am told otherwise, I will leave this post open incase someone finds a function or other that will return the filename and would like to post it up on here.

rfind is what you want:

sPath = event.source.parent.getComponent('File Explorer').selectedPath
sFileName = None
if sPath.rfind(".") != -1:
	if sPath.rfind("\\") != -1:
		sFileName = sPath[sPath.rfind("\\")+1:sPath.rfind(".")]
	elif sPath.rfind("/") != -1:
		sFileName = sPath[sPath.rfind("/")+1:sPath.rfind(".")]
if sFileName == None:
	sFileName = ""
print sFileName

I also like this, if you know which system you are on and don’t mind the file extension:

fileName = filePath.split("\\")[-1]

I use the split() method. It returns a nice list for you to do whatever you want with. There’s nothing built into the component like this.