DirectoryFunctions.

GetParentDirectory(string) Method

Summary

Retrieves the parent directory of the specified path.
Assembly
NAnt.Core.dll
Namespace
NAnt.Core.Functions
Containing Type
DirectoryFunctions

Syntax

[Function("get-parent-directory")]
public string GetParentDirectory(string path)

Examples

Copy "readme.txt" from the current working directory to its parent directory.

    <property name="current.dir" value="${directory::get-current-directory()}" />
<property name="current.dir.parent" value="${directory::get-parent-directory(current.dir)}" />
<copy file="${path::combine(current.dir, 'readme.txt')} todir="${current.dir.parent}" />

Attributes

Type Description
FunctionAttribute Indicates that the method should be exposed as a function in NAnt build files.

Parameters

Name Type Description
path string The path for which to retrieve the parent directory.

Return Value

Type Description
string The parent directory, or an empty string if path is the root directory, including the root of a UNC server or share name.