Remove Path From File Name
Asked Answered
L

3

6

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?

Linearity answered 8/1, 2010 at 21:20 Comment(1)
+1 for figuring out the first half yourselfFarrel
F
19

Just add ExtractFileName(FName);

Farrel answered 8/1, 2010 at 21:28 Comment(1)
Thank you. I am working on an MP3 Editor, and that is what I needed.Landowska
C
7

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

Charentemaritime answered 8/1, 2010 at 21:26 Comment(0)
E
0

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

Est answered 8/9, 2017 at 11:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.