Unrelated I would strongly advice using the File methods for modifying paths and ascending/descending the file tree:
File::getSpecialLocation() or chooser.getFiles() as starting point and from there using getParentDirectory() and getChildFile(“foo”).
That is definitely portable regarding of slash and backslash etc.
Oh, I see my problem. The function returns a copy of the string. It doesn’t modify the string itself. (My code posted above was not what I actually used, which tried to use that function in place.)
The name made me think it was trimming the string itself, not creating a new string. Something like withCharactersTrimmedFromEnd() would have been more obvious.
Thanks! Carry on!