You should use the PathUtils functions for extracting the path and filename.