NAnt SDK Documentation - v0.92 |

# DirectoryFunctions.GetParentDirectory Method

Retrieves the parent directory of the specified path.

[Visual Basic]
<Function(Name:="get-parent-directory")>
Public Function GetParentDirectory( _
ByVal path As String _
) As String
[C#]
[Function(Name="get-parent-directory")]
public string GetParentDirectory(
string path
);

#### Parameters

path
  The path for which to retrieve the parent directory.

#### Return Value

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

#### Exceptions

Exception Type | Condition
--- | ---
IOException | The directory specified by path is read-only.
ArgumentException | path is a zero-length string, contains only white space, or contains one or more invalid characters.
PathTooLongException | The specified path, file name, or both exceed the system-defined maximum length.
DirectoryNotFoundException | The specified path was not found.

#### Example

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}" />

#### See Also

DirectoryFunctions Class | NAnt.Core.Functions Namespace