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();
var files = web.Lists["Allegati"].items
|improve this answer|||||
  • Remove dot between Lists and ["Allegati"] – Louis Apr 26 '12 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.

|improve this answer|||||

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.