Query to get all items in a list including items i

2019-03-02 15:29发布

问题:

I have a document library list. I created folders in that list and uploaded some files to those sub folders. How to get all these files which are in sub-folders in that document library list using SPQuery?

回答1:

If you want to query all folders and sub folders of a list or document library, you have to define extra query options. If you are working with the object model you have to set the ViewAttributes property of the SPQuery object as follows:

qry.ViewAttributes = "Scope='Recursive'";