Share via


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

Syntax

'Declaration
<ClientCallableAttribute> _
<ClientCallableConstraintAttribute(Type := ClientCallableConstraintType.NotNull)> _
<ClientCallableConstraintAttribute(Type := ClientCallableConstraintType.ServerRelativeUrl)> _
Public ReadOnly Property ServerRelativeUrl As String
    Get
'Usage
Dim instance As SPFile
Dim value As String

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

Property Value

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

Remarks

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.

See Also

Reference

SPFile Class

SPFile Members

Microsoft.SharePoint Namespace