CAML query result on SharePoint library not showing folders data?

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.
LVL 10
Minesh ShahSharePoint & all about itAsked:
Who is Participating?
 
ivan_vaguninConnect With a Mentor Commented:
Hi!

Add following before GetItems():
query.ViewAttributes = "Scope=\"Recursive\"";
This will make query items in all subfolders.
0
 
Minesh ShahSharePoint & all about itAuthor Commented:
done, working
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.