RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.ExtractFileExt Function

Returns the extension portions of a file name.

Pascal
function ExtractFileExt(const FileName: string): string;
C++
AnsiString ExtractFileExt(const AnsiString FileName);

SysUtils

Use ExtractFileExt to obtain the extension from a file name. For example, the following code returns the extension of the file name specified by a variable named MyFileName: 

MyFilesExtension := ExtractFileExt(MyFileName); // Delphi 

MyFilesExtension = ExtractFileExt(MyFileName); // C++ 

The resulting string includes the period character that separates the name and extension parts. This string is empty if the given file name has no extension.

Note: This function works for multi-byte character systems (MBCS).
 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!