How to remove folder path from file name string

Hi, how do I remove the folder path from the complete file path?

E.g. from “C:\Folder1\Folder2\ProjectFolder\Folder3\Folder4\File.xlsx” to just “File.xlsx”

Environment.CurrentFolder just returns up to C:\Folder1\Folder2\ProjectFolder and I don’t really want to key in every folder after that manually


Path.getFileNameWithOutExtension(“fullpath”) - it will give you file name only.

Path.GetFileName(filepath) - it gives full path including extension.
If you don’t extension you can use like @lakshman mentioned above.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.