2016-05-12 133 views

回答

0

實際上一個項目總是一個項目(SPListItem對象)。
如果您從庫中獲取某個項目,則必須使用SPItem.File來獲取適當的SPFile對象。

爲確保您擁有一個文件,您可以使用SPFile(請參閱https://msdn.microsoft.com/EN-US/library/microsoft.sharepoint.spfile.exists.aspx)的Exists屬性。

... 
var item = GetListItemById(1); 
if (item.File.Exists) 
{ 
    var file = item.File; 
    //handle file 
} 
... 

HTH,
丹尼爾

相關問題