Web.GetFileByServerRelativeUrl Method
Returns the file object located at the specified server-relative URL.
Namespace: Microsoft.SharePoint.Client
Assemblies: Microsoft.SharePoint.Client.Silverlight (in Microsoft.SharePoint.Client.Silverlight.dll); Microsoft.SharePoint.Client (in Microsoft.SharePoint.Client.dll)
Syntax
'Declaration
<RemoteAttribute> _
Public Function GetFileByServerRelativeUrl ( _
serverRelativeUrl As String _
) As File
'Usage
Dim instance As Web
Dim serverRelativeUrl As String
Dim returnValue As File
returnValue = instance.GetFileByServerRelativeUrl(serverRelativeUrl)
[RemoteAttribute]
public File GetFileByServerRelativeUrl(
string serverRelativeUrl
)
Parameters
serverRelativeUrl
Type: System.StringA string that specifies the server-relative URL for the file.
Return Value
Type: Microsoft.SharePoint.Client.File
A File object that represents the file.
Exceptions
Exception | Condition |
---|---|
ArgumentException | The serverRelativeUrl does not start with a '/' or serverRelativeUrl does not correspond to a file. |
Remarks
It must not be a null reference (Nothing in Visual Basic). It must not be empty.