On Tue, May 21, 2019 at 2:18 PM James Richters <ja...@productionautomation.net> wrote:
> Function ExtractFilePathAndNameWithoutExt(Filenametouse:String):String; > > Begin > > ExtractFilePathAndNameWithoutExt := > copy(Filenametouse,1,rpos(ExtractFileExt(Filenametouse),Filenametouse)-1); > > End; From LazFileUtils unit: function ExtractFileNameWithoutExt(const AFilename: string): string; var p: Integer; begin Result:=AFilename; p:=length(Result); while (p>0) do begin case Result[p] of PathDelim: exit; {$ifdef windows} '/': if ('/' in AllowDirectorySeparators) then exit; {$endif} '.': exit(copy(Result,1, p-1)); end; dec(p); end; end; writeln(ExtractFileNameWithoutExt('c:\foo\bar\foobar.ext')); gives: c:\foo\bar\foobar -- Bart _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal