Function to get the file's path 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

File path with a backward slash ("\") at the end; the file's name and extension are ignored.

 

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

ExtractFileExt

ExtractFileName

mLogScript