SPUtility.GetUrlDirectory Method

Returns the directory-path part of the URL.

Namespace:  Microsoft.SharePoint.Utilities
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

public static string GetUrlDirectory(
	string url
)

Parameters

url
Type: System.String

The URL path.

Return Value

Type: System.String
A string that contains the directory path of the URL.

If the url parameter is http://server/web/list/folder/file.txt, the returned directory part is "http://server/web/list/folder".

Show: