.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

query to get Items from sub folders in a document library

Posted By:      Posted Date: October 06, 2010    Points: 0   Category :SharePoint



i am having a document library  MY LIBRARY with SUB Folders SUB 1, SUB 2,SUB 3 ,SUB 4


i need to retreive documents in SUB 1, SUB 2 only

How can i write CAML query for this?

If need to retreive from one sub folder, i am using


qry.Folder = list.ParentWeb.GetFolder("MY LIBRARY /SUB 1");


Thanks and Regards,




View Complete Post

More Related Resource Links

Content Query Web Part (CQWP) fails to show picture items from a document/picture library in an anon

I have a Picture Library and am trying to use the CQWP to display a list of items in the library.  The web part shows the items fine in authenticated mode, but it fails to show the items to anonymous users. The error log message is: Error while executing web part: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.SetDocumentIconUrlAndOnClickString(SPWeb web, DataRow row, String strDefaultItemOpen, Boolean fSetDocIcon, Boolean fSetOnClick, String fileRefColumnRef, String progIdColumnRef, String fsobjTypeColumnRef, String permMaskColumnRef)     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.PreProcessForDocumentIconAndOnClickAttribute()     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.AddContentQueryData()     at Microsoft.SharePoint.Publishing.WebControls.ContentByQueryWebPart.GetXPathNavigator(String viewPath)     at Microsoft.SharePoint.WebPartPages.DataFormWebPart.PrepareAndPerformTransform(Boolean bDeferExecuteTransform) I'm running SP 2010.  I've tried various scenarios including: 1. Using the default publishing template. 2. Using the blank site template with publishing and lock down features enabled. 3. Us

Document Library View - "Folders or Flat --> Show all items without folders" setting not being saved


A view of a document library has a setting under Folders area if the files should be shown in their respective folder or just a flat list of file. If "Show all items withtout folders" is selected, following is my observation:

- Saving the document library as a template and creating new libraries from this template takes this setting into the new library as expected
- Saving the site as a template and creating a new site from template removes this setting from the existing document libraries in newly created sites. If a new document library is created from the document library template, the setting is ON as expected.

This seems to be related to what being discussed here http://stackoverflow.com/questions/3574095/hiding-folder-structure-for-a-view-in-sharepoint-2010-list-definition and http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/05e46fc9-cb26-4d00-aaf0-e4b6ee944104

Any feedback?

how to exclude folders(and items within this folder) under document library in search result?

I have a library with a particular content type. I also have a folder _thumbs within it. I do not want the search to retrieve the items that are within this folder (or the folder for that matter). Any ideas on how this can be achieved?
Sharepoint Dummy

Cannot add SQL Server 2008 R2 Report items to SharePoint Server 2010 document library

Using account which is the primary parent site administrator, can upload RDS and RDL files to the document library (however, cannot open report). User is also a domain admin with SA on the database instances. Cannot add Report Data Source with "New Document" icon. The permissions granted to user '[domain]\[user]' are insufficient for performing this operation. Under "Site Settings", "Managed Shared Schedules" fails with same error. Attempting to deploy from BIDS results in the same permissions error. Sharepoint Server 2010, Report Server 2008 R2. RS and SP databases hosted on remote server (SQL Server 2008 R2). All connections (SharePoint services, RS services, users) except SQLAgent authenticating to remote SQL Server with Kerberos (all SPNs look correct). Single site, site collection "/". Document directory called "Reports". Windows Integrated Security (Negotiate). How would I troubleshoot/solve problem?

Listing documents in Folders and subfolders in a Dataview of Document Library

My dataview is pointed to a Document Library. I noitced files in folders and subfolders don't list - only the folders themselves.  Is there any way to list files in a particular folder or all files in all folders? What I'm trying to do is tie a folder to entries in a custom list. I'd like a folder for every ID in that custom list. When I open the Dispform for the ID, I'd like a dataview or some other webpart to dynamically to show related files (all which would ofcourse just be in their respective folder). I'm thinking it's just a matter of passing the ID querystring to a condition in the Dataview or Webpart. It would also have to be a folder as I need to allow same file names to be uploaded.   Thanks.  

How to add more items link in document library?

Hi, I have a document library, i need to display limit number of items with "more items" link. if i click more items link it will display all the items in the document library. how to create more items link in document library? thanks.

I want to upload Folders which contain special characters into the sharepoint document library

I want to upload Folders which contain special characters into the sharepoint document library

Change Document Library default action on Items



I have a standard Document Library where I uploaded various  kinds of file (.pdf, swf). Whenever I click on an item (or I paste its direct link into the browser) it prompts me to download it instead of opening it into the browser directly (with flash player or acrobrat in my example).

How to obtain the desired behavior? Thanks

can i access sharepoint 2007 'Document Library' items into WPF directly. or iwant to use any WCF o


please suggest me.

and give the proper coading..

thanks for any help

Determine permissions for a document library with nested folders


I have a document library with many nested folders.  Each folder has unique permissions.  Is there a way to get a report of all permissions assigned to this document libary/folders? 

Different views within folders inside a document library


has anyone worked out how to do different views in Folders inside a document library ?


Sharepoint Customiser

Same file name, different folders. Store in document library separately


When I set up a document library in SharePoint 2007 (with versioning), I want to upload files with the same file name, but in different folders. I want each of the the files to have it's own version history. The files must remain distinct, as they are entirely different files with their own context in a folder hierarch.

Can I do this? How?

You can probably tell I am brand new to using SharePoint.


Jon Jacobs This message was composed entirely from recycled electrons.

Content Query Web Part - Filter Contents of Document Library



I would like to display selective content of document library using content query web part. My document library has multiple folders. I would like to have the content query web part display the contents of one particular folder. And also another content query should display the contents based on a column in the document library. I don't see these options when customizing the query for the content query web part. If this is not possible by default, what is the potentail alternative solution ?



Srikanth Reddy

Search multiple document library in Query


How to search multiple document library in a sitecollection. these document library has same named : DocLib1, DocLib2, DocLib3 ... they all in a same sitecollection.

How to search document via FullTextSqlQuery or other Search Objects?

If there is another sitecollection structured similiary with this one, how to search all these document library? Can we search all sites documents then use url for filter ?

Thanks a lot.


Unable to perform fulltext search for documents in some folders in an SharePoint Document Library


Issue Description : Keywords from certain folders in the Document Library  is not searchable via full text search. For example, the keyword “4MB7106” is not searchable, even though the document is available in the document library. This is content search in a file in a document library, NOT a file name. Any ideas?

list of document library items' permissions


Hi All,

There is a library (SharePoint Server 2007)

There are many files in this library (with personal permissions).

QUESTION: How to obtain the list of these files with their permissions.


Specifying path to external items (Sharepoint Document Library)


I continue to have trouble getting a subreport to display from within a main report that is stored in a SharePoint Foundation 2010 document library.  My report server is configured in SharePoint Integrated Mode.

A TechNet article, Specifying Paths to External Items (Report Builder 3.0 and SSRS) [http://technet.microsoft.com/en-us/library/dd220423.aspx], includes the following instructions:

When you specify a path for an external item in a dialog box for actions, subreports, or images, you can browse directly to the report server and select the item. Browsing to an item and selecting it directly is the recommended way to specify a drillthrough report or subreport. That way the correct parameter names will be available in a drop-down list when you specify report or subreport parameters. When you change an item path to point to a different item, you must manually update the correct parameter names and values as needed.

On a report server configured in SharePoint integrated mode, you must include the file extension .rdl. The path can be one of the following:

  • A full path to the item.  On a SharePoint site: You must specify the report name in an expression, with the full URL of the item and the file extension .rdl. For example, ="http://server/site/lib
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend