NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

File.GetDirectoryNameFromPath

Returns the directory path of a file.

[Visual Basic]
Public Shared Function GetDirectoryNameFromPath( _
   ByVal path As String _
) As String
[C#]
public static string GetDirectoryNameFromPath(
   string path
);
[C++]
public: static String* GetDirectoryNameFromPath(
   String* path
);
[JScript]
public static function GetDirectoryNameFromPath(
   path : String
) : String;

Parameters

path
The path of a file or directory.

Return Value

The directory path of the given path, or a null reference (in Visual Basic Nothing) if the given path denotes a root.

Exceptions

Exception Type Condition
ArgumentException path contains invalid characters.
ArgumentException path is empty or contains only whitespaces.

Remarks

This method effectively removes the last element of the given file path, returning a string consisting of all characters up to but not including the last backslash ("\") in the file path. The returned value is null if the file path is null or if the file path denotes a root (such as "\", "C:", or "\\server\share").

See Also

File Class | File Members | System.IO Namespace