Question

I'm developing a program that needs to parse the file name into a TTextField. How to remove the file extension I've already know(or think that I can do like this):

var
  FName: String;
  FPath: String;

begin
  FPath := OpenDialog1.FileName;
  FName := ChangeFileExt(FPath, '');
end;

But how can I remove the file path from FName?

Was it helpful?

Solution

Just add ExtractFileName(FName);

OTHER TIPS

Take a look at SysUtils.ExtractFileName. I think that's what you're looking for.

In newer Delphi versions there is also TPath.GetFileName from System.IOUtils

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top