Share via


GetDirectoryName Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Returns the directory information for the specified path string.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

Syntax

'Declaration
Public Shared Function GetDirectoryName ( _
    path As String _
) As String
public static string GetDirectoryName(
    string path
)
public:
static String^ GetDirectoryName(
    String^ path
)
static member GetDirectoryName : 
        path:string -> string 
public static function GetDirectoryName(
    path : String
) : String

Parameters

Return Value

Type: System. . :: . .String
Directory information for path, or nullNothingnullptrunita null reference (Nothing in Visual Basic) if path denotes a root directory or is null. Returns String..::..Empty if path does not contain directory information.

Remarks

In most cases, the string returned by this method consists of all characters in the path up to but not including the last DirectorySeparatorChar. If the path consists of a root directory, such as "c:\", null is returned. Note that this method does not support paths using "file:". Because the returned path does not include the DirectorySeparatorChar, passing the returned path back into the GetDirectoryName method will result in the truncation of one folder level per subsequent call on the result string. For example, passing the path "C:\Directory\SubDirectory\test.txt" into the GetDirectoryName method will return "C:\Directory\SubDirectory". Passing that string, "C:\Directory\SubDirectory", into GetDirectoryName will result in "C:\Directory".

.NET Framework Security

See Also

Reference

Path Class

System.IO Namespace