Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Retrieves the file object located at the specified URL.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
Syntax
'Declaration
Public Function GetFile ( _
strUrl As String _
) As SPFile
'Usage
Dim instance As SPWeb
Dim strUrl As String
Dim returnValue As SPFile
returnValue = instance.GetFile(strUrl)
public SPFile GetFile(
string strUrl
)
Parameters
strUrl
Type: System.StringThe URL for the file.
Return Value
Type: Microsoft.SharePoint.SPFile
The file object with the specified URL.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | strUrl is null . |
ArgumentException | strUrl is or empty. |
Remarks
This method calls the SPFile constructor with this and strUrl.
Examples
The following code example loads the default.aspx file.
SPFile file = web.GetFile(“default.aspx”);
if(file.Exists) // here, this condition will return always false
{
// …
}