Solved

CAML query result on SharePoint library not showing folders data?

Posted on 2012-04-04
2
1,712 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

726 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