Author: Tomas Rutkauskas
How to get only file name (without extension) ? Example: If i have:
c:\test\other\anyfile.doc and i want get only "anyfile".
Answer:
//Solve 1:
1 function FileName(Value: string): string;
2 begin3 Result := ExtractFileName(Value);
4 if ExtractFileExt(Value) <> '' then5 Result := Copy(ExtractFileName(Value), 1,
6 Pos(ExtractFileExt(Value), ExtractFileName(Value)) - 1);
7 end;
8 9 10 //Solve 2:11 12 function FileName(Value: string): string;
13 begin14 Result := ChangeFileExt(ExtractFileName(Value), '');
15 end;