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:
Download Windows Search API (http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=7388)
Import Micosoft.Search.Interop namespace.
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();