I am using angular and in my .ts file I want to get the filename of a path path without the extension.
So here is the full path + filename:
const fullpath = ["C:\Users\my.user\Desktop\the_filename.txt"]
I've been trying this:
getFileNameOnly() {
var fileName = "C:\Users\my.user\Desktop\the_filename.txt";
var res = fileName.substr(fileName.lastIndexOf('.') + 1);
console.log(res);
}
This above returns error:
TypeError: fileName.substr is not a function
How can I do this so that the result is:
"the_filename"
?