Function to get the file's name from the text string.

 

Syntax

function ExtractFileExt(sFileName:string): string;

 

Parameters and return values

Parameter

Type

Value

sFileName

string

file name or path

 

Function result

Full name of the file with extension (without path).

 

Example

begin
var
  sFullName, sPath, sName, sExt: string;
  sFullName := mGetServerServiceFolder(3) + 'mcserv.exe';
  
  sPath := ExtractFilePath(sFullName);
  sName := ExtractFileName(sFullName);
  sExt  := ExtractFileExt(sFullName);
  
  mLogScript('Full name: ' + sFullName, '');
  mLogScript('Path: ' + sPath, '');
  mLogScript('Name: ' + sName, '');
  mLogScript('Extension: ' + sExt, '');
end.

Script work result

[20:17:51] (Log "ExtractFileParts"): Full name: E:\Projects\MC\Sources\Server\mcserv.exe

[20:17:51] (Log "ExtractFileParts"): Path: E:\Projects\MC\Sources\Server\

[20:17:51] (Log "ExtractFileParts"): Name: mcserv.exe

[20:17:51] (Log "ExtractFileParts"): Extension: .exe

[20:17:51] (Run "ExtractFileParts"): Script operation time: 5 ms

[20:17:51] (Run "ExtractFileParts"): Script done successfully.
 

See also

ExtractFilePath

ExtractFileExt

mLogScript