Solved

CAML query result on SharePoint library not showing folders data?

Posted on 2012-04-04
2
1,677 Views
Last Modified: 2012-04-05
Hi, I am writing a code to retrieving files from SharePoint library based on properties value using CAML query, below is the code:
------------------------------------------------------------------------------------------------------------------------------------------------
SPList mylist = myWeb.Lists["MIS"]; //MIS is the SharePoint library
SPQuery query = new SPQuery();
query.Query = "<Where><Eq><FieldRef Name='Domain'/><Value Type='Text'>External</Value></Eq></Where>";
SPListItemCollection items = mylist.GetItems(query);
foreach (SPListItem item in items)
{ Response.Write(SPEncode.HtmlEncode(item["Title"].ToString()) + "<BR>"); }  
--------------------------------------------------------------------------------------------------------------------------------------
Above code is showing only first level of files means if files are uploaded within folders then that files are not coming in result.

Can anyone help me to get folders data also.
0
Comment
Question by:Minesh Shah
2 Comments
 
LVL 18

Accepted Solution

by:
ivan_vagunin earned 500 total points
ID: 37807565
Hi!

Add following before GetItems():
query.ViewAttributes = "Scope=\"Recursive\"";
This will make query items in all subfolders.
0
 
LVL 10

Author Closing Comment

by:Minesh Shah
ID: 37815182
done, working
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now