0

Hi I'm trying to get file from a documentLibray with LINQ Query. I've been trying with this code but I get nothing!

 var allegatiCollegati = (from SPFile attach in web.Lists.["Allegati"].items

                         select attach ).ToList();
3
var files = web.Lists["Allegati"].items
.Cast<SPListItem>()
.Where(item=>item.File!=null)
.Select(item=>item.File)
.ToList();
  • Remove dot between Lists and ["Allegati"] – Louis Apr 26 '12 at 1:54
1

SPList.Items (web.Lists.["Allegati"].Items) returns an SPListItemCollection collection, which contains SPListItem and not SPFile objects. You can get the SPFile from the SPListItem by calling SPListItem.File.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.