共用方式為


SPList.AddItem method (String, SPFileSystemObjectType, String)

使用指定的檔案名稱中指定的資料夾清單中,會建立指定之類型的清單項目。

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

Syntax

'宣告
Public Function AddItem ( _
    folderUrl As String, _
    underlyingObjectType As SPFileSystemObjectType, _
    leafName As String _
) As SPListItem
'用途
Dim instance As SPList
Dim folderUrl As String
Dim underlyingObjectType As SPFileSystemObjectType
Dim leafName As String
Dim returnValue As SPListItem

returnValue = instance.AddItem(folderUrl, _
    underlyingObjectType, leafName)
public SPListItem AddItem(
    string folderUrl,
    SPFileSystemObjectType underlyingObjectType,
    string leafName
)

參數

  • folderUrl
    Type: System.String

    伺服器相對 URL 的清單項目應建立所在的資料夾。URL 開頭應該是正斜線 ;例如, /sites/mysite/subweb/Lists/mylist/myfolder。

  • leafName
    Type: System.String

    檔案名稱,包括副檔名 ;例如, mydoc.doc。如需詳細資訊,請參閱 < Name屬性。

傳回值

Type: Microsoft.SharePoint.SPListItem
新的清單項目。

Exceptions

Exception Condition
ArgumentOutOfRangeException

underlyingObjectTypeFile是也不是Folder

備註

若要新增項目至清單,請先呼叫AddItem方法,以指定的檔案名稱中指定的資料夾建立指定類型的清單項目。若要指派特定的值,每個欄位的項目,然後傳回的SPListItem物件上使用索引器。最後,將變更寫入至資料庫SPListItem物件上呼叫Update方法。

重要

新的項目不會實際新增至清單上,直到您將它儲存到的內容資料庫呼叫SPListItem.Update方法。

請參閱

參照

SPList class

SPList members

AddItem overload

Microsoft.SharePoint namespace

FileSystemObjectType

Url

Name