Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SPWeb.GetFile method (String)

Retrieves the file object located at the specified URL.

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

public SPFile GetFile(
	string strUrl
)

Parameters

strUrl
Type: System.String

The URL for the file.

Return value

Type: Microsoft.SharePoint.SPFile
The file object with the specified URL.

ExceptionCondition
ArgumentNullException

strUrl is null .

ArgumentException

strUrl is or empty.

This method calls the SPFile constructor with this and strUrl.

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
    {
      // …
    }
Show:
© 2015 Microsoft