SPFile.ServerRelativeUrl Property

Gets the relative URL of the file based on the URL for the server.

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

[ClientCallableAttribute]
[ClientCallableConstraintAttribute(Type = ClientCallableConstraintType.NotNull)]
[ClientCallableConstraintAttribute(Type = ClientCallableConstraintType.ServerRelativeUrl)]
public string ServerRelativeUrl { get; }

Property Value

Type: System.String
A string that contains the URL.

The ServerRelativeUrl property returns a string in the following form, which excludes the name of the server or root folder: /Site_Name/Subsite_Name/Folder_Name/File_Name.

For information about the forms of URLs that are used in Microsoft SharePoint Foundation, see Guidelines for Using the Object Model.

Show: