Split File Path into FileName and FilePath

I’m receiving a FolderItem, with a Name such as “C:\Users\Documents\Hill Project\bid_001.doc” and I would like to split it into two components: the file name and the path to the file. I will end up with two strings: file name (“bid_001.doc”) and file path (“C:\Users\Documents\Hill Project”). Is there a function that lets me do this with a FolderItem already?

Thank you!

does the file exist ?
and all the directories to it ?
i so you can use GetFolderitem( path, Folderitem.PathTypeNative) to get a reference to is and then you can get the name from that with one line

if not then Split is your friend
Split on \ and the last chunk is the name and everything else is the path to it

I’m receiving a FolderItem of a file that exists. I’m just wanting to get the file name only for tracking/display purposes. I was looking for something like FolderItem.PathToFile and FolderItem.FileNameOnly methods. :slight_smile: I’ll just write them myself.

Thank you!

FolderItem.Name will give you the file name, FolderItem.Parent.NativePath will give you the path.

Thank you, @Wayne Golding! That is nice and easy.