System.IOUtils.TPath.GetFileNameWithoutExtension

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

class function GetFileNameWithoutExtension(const FileName: string): string; static;

C++

static System::UnicodeString __fastcall GetFileNameWithoutExtension(const System::UnicodeString FileName);

Properties

Type Visibility Source Unit Parent
function public
System.IOUtils.pas
System.IOUtils.hpp
System.IOUtils TPath

Description

Extracts the name part of a file name, without extension.

GetFileNameWithoutExtension extracts the name part of the given file name, omitting the extension. The resulting string consists of the leftmost characters of FileName, starting with the first character after the colon or backslash that separates the path information from the name and up to the period that is part of the extension, but not including either the dot or the extension itself. If there are more than one period, GetFileNameWithoutExtension stops just before the last one that is considered part of the extension.

For instance,

  Writeln(TPath.GetFileNameWithoutExtension('D:\Testing\MyApp.exe'));
  Writeln(TPath.GetFileNameWithoutExtension('D:\Testing\MyApp.exe.config'));

produces

  MyApp
  MyApp.exe

The resulting string is equal to FileName if FileName contains no drive, directory, and extension parts. The following table lists the parameters expected by this method.

Name Meaning

FileName

The file name from which the name is extracted.

Note: GetFileNameWithoutExtension raises an exception if the given file name contains invalid characters.

See Also