CSC510226. Do not use SPListItem.File.

Description

For non document library it returns null.

Resolution

Check that you work with document library. Use SPWeb.GetFile(SPListItem.UniqueId) instead.

SPListItem item;
var file = item.Web.GetFile(item.UniqueId);

Links

SPListItem.File property

Last edited Mar 13, 2014 at 3:03 PM by dvd73, version 3

Comments

Aviw Aug 6, 2014 at 7:51 AM 
What does "item.Web.GetFile()" return?
Why can't I check it (SPListItem.File) for null?