How to add folder into windows indexing list with windows search api

亡梦爱人 提交于 2019-12-06 03:18:02

问题


In Indexing Options, there’s a list of locations in ‘Index these locations’, is there a way to add a folder which created from my app into the list through c#?


回答1:


I have found a solution, anyone who want to let their app folder to support windows search in C# can do like below:

  1. Download Windows Search API (http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=7388)

  2. Import Micosoft.Search.Interop namespace.

  3. write the code

    Uri path = new Uri(location);
    
    string indexingPath = path.AbsoluteUri;
    
    CSearchManager csm = new CSearchManager();
    CSearchCrawlScopeManager manager = csm.GetCatalog("SystemIndex").GetCrawlScopeManager();
    manager.AddUserScopeRule(indexingPath, 1, 1, 0);
    manager.SaveAll();
    


来源:https://stackoverflow.com/questions/20793938/how-to-add-folder-into-windows-indexing-list-with-windows-search-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!