I have the following string:
string path = "C:\Users\Username\Desktop\FileName.pdf";
I need to take off FileName.pdf and put in a string variable called fileName.
The code has to be generic in a sense that anytime i get path, i start
going from the end of the string down to the first backslash.
I’m using C#
You can use
System.IO.Pathto manipulate a path.For completeness here’s the code: