Correctly strip the file extension in the `File` class (see #6968)