There is a document on the SharePoint server, its location is unknown, how can you find it using C#(.NET) without recourse to the search service, i.e. let's say I want to develop my custom search?

closed as too broad by Christoffer, MHeld, Mohamed El-Qassas MVP Feb 10 at 22:03

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


You would need to iterate through all of the objects:

    SPSite (Site collections)
      SPWeb  (sites)
        SPList  (and filter for just libraries)

You would only be able to search in the document's metadata (name, created by, library columns, etc.) and not by keyword within the document. (Unless you want to open and parse the content of all of the files / file types.)

At the Site Collection level you use a SPSite​Data​Query CAML Query to search the Site Collection. https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-server/ms409088(v=office.15)

This would be very slow compared to a SharePoint Search. Why do you not want to call the Search API?

  • 1
    I too am curious. There was a comparison paper done several years ago comparing data access methods. Search was something like 58 times faster than enumeration for a small farm. – Matthew McDermott Feb 8 at 22:44
  • Mike thanks you, tell me, why can't I search inside documents by keywords? use for example library Microsoft.Office.Interop.Word? – Fox Feb 11 at 7:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.