Web.GetFileByServerRelativeUrl method

Returns the file object located at the specified server-relative URL.

Namespace:  Microsoft.SharePoint.Client
Assembly:  Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)

public File GetFileByServerRelativeUrl(
	string serverRelativeUrl
)

Parameters

serverRelativeUrl
Type: System.String

A string that specifies the server-relative URL for the file.

Return value

Type: Microsoft.SharePoint.Client.File
A File object that represents the file.

ExceptionCondition
ArgumentException

The serverRelativeUrl does not start with a '/' or serverRelativeUrl does not correspond to a file.

It must not be a null reference (Nothing in Visual Basic). It must not be empty.

Show: