SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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();
share|improve this question
var files = web.Lists["Allegati"].items
share|improve this answer
Remove dot between Lists and ["Allegati"] – Louis Apr 26 '12 at 1:54
removed, thanks to point out~ – Eric Apr 26 '12 at 7:27

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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