Please enable JavaScript to view this site.

Codolex

Get path part can be useful for getting different parts of a path you have. If you want to get the file name only from a path for example.

uses System.IOUtils.TPath Methods

 

GetPartPath

Activity properties

 

There are six different parts to retrieve from a path.

 

Directory name

Gets the directory name of the file path.

 

Example:

Filepath = 'C:\Users\Username\Documents\Codolex\Project.fcp'.

 

begin

var PathPart: string;

 PathPart := TPath.GetDirectoryName(FilePath);

end;

Result = 'C:\Users\Username\Documents\Codolex'

 

File name

Gets the file name plus extension of the file path.

 

Example:

Filepath = 'C:\Users\Username\Documents\Codolex\Project.fcp'.

 

begin

var PathPart: string;

 PathPart := TPath.GetFileName(FilePath);

end;

Result = 'Project.fcp'

 

File name without extension

Gets the file name without extension of the file path.

 

Example:

Filepath = 'C:\Users\Username\Documents\Codolex\Project.fcp'.

 

begin

var PathPart: string;

 PathPart := TPath.GetFileNameWithoutExtension(FilePath);

end;

Result = 'Project'

 

Extension

Gets the extension of the file path.

 

Example:

Filepath = 'C:\Users\Username\Documents\Codolex\Project.fcp'.

 

begin

var PathPart: string;

 PathPart := TPath.GetExtenstion(FilePath);

end;

Result = '.fcp'.

 

Full path

Gets the full path of the file path.

 

Example:

Filepath = 'C:\Users\Username\Documents\Codolex\Project.fcp'

 

begin

var PathPart: string;

 PathPart := TPath.GetFullPath(FilePath);

end;

Result = 'C:\Users\Username\Documents\Codolex\Project.fcp'

 

Root path

Gets the root path of the file path.

 

Example:

Filepath = 'C:\Users\Username\Documents\Codolex\Project.fcp'

 

begin

var PathPart: string;

 PathPart := TPath.GetPathRoot(FilePath);

end;

Result = 'C:\'

 

Providing an incorrect path will not result in errors, but may have unexpected outcomes.

 

© by GDK Software