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)

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.