PathFileName Procedure
Gets the filename part of a path, dropping the directory part.
Use
PathDirectoryName to return the directory part of the path.
This is done by extracting the last path component from the string.
No disk access is performed and the path does not need to actually exist.
Declaration
function PathFileName(path as String) as String
Parameters
- path as String — Path to a directory or file.
Return value
String — Last path component.
Example
Code
dim path = "C:\Users\user\Documents\myfile.txt"
print PathDirectoryName(path)
print PathFileName(path)
Output
C:\Users\user\Documents
myfile.txt