Re: GetExtensionPart fails with a space
Posted: Thu Jul 31, 2025 1:53 am
This is what I'm using now, since it covers all situations (spaces, multiple dots, dots at the start and end, dots in the path):
Code: Select all
Procedure.s GetFileExtension(file$)
ext$=GetExtensionPart(file$)
If ext$="" And Right(file$,1)<>"."
dots=CountString(file$,".")
If dots
ext$=StringField(file$,dots+1,".")
EndIf
EndIf
ProcedureReturn ext$
EndProcedure
Debug GetFileExtension("C:\File Path\.John Doe") ; John Doe
Debug GetFileExtension("C:\File Path\Name. . .John Doe") ; John Doe
Debug GetFileExtension("C:\File.Path\Name....John Doe....") ; "" (correct)