Today I will talk about a little trick that a friend gave me recently.
Having used to work with SPQuery, I was already familiar with the attribute needed to query all the file within list’s folder:
SPQuery.ViewAttributes = "Scope='Recursive'";
But recently I learned of another attribute to filter only on documents approved! Indeed there is an attribute “ModerationType” !
SPQuery.ViewAttributes = " ModerationType='HideUnapproved'";
And so if we want to make our request only on our approved documents, we will add the following attributes to our SPQuery.
SPQuery.ViewAttributes = "Scope='Recursive' ModerationType='HideUnapproved'";
Hope this helps!