共用方式為


SPWeb.GetFile method (String)

擷取位於指定 URL 的檔案物件。

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

Syntax

'宣告
Public Function GetFile ( _
    strUrl As String _
) As SPFile
'用途
Dim instance As SPWeb
Dim strUrl As String
Dim returnValue As SPFile

returnValue = instance.GetFile(strUrl)
public SPFile GetFile(
    string strUrl
)

參數

傳回值

Type: Microsoft.SharePoint.SPFile
具有指定的 URL 的檔案物件。

Exceptions

Exception Condition
ArgumentNullException

strUrl是 null 。

ArgumentException

strUrl或空的。

備註

這個方法會呼叫this與strUrl的SPFile建構函式。

Examples

下列程式碼範例會載入default.aspx檔案。

SPFile file = web.GetFile("default.aspx");
    if(file.Exists) // here, this condition will return always false
    {
      // …
    }

請參閱

參照

SPWeb class

SPWeb members

GetFile overload

Microsoft.SharePoint namespace