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();

2 Answers 2

var files = web.Lists["Allegati"].items
  • Remove dot between Lists and ["Allegati"]
    – Louis
    Apr 26, 2012 at 1:54

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 and acknowledge you have read our privacy policy.

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