Solved

CAML query result on SharePoint library not showing folders data?

Posted on 2012-04-04
2
1,689 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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