2017-05-07 21 views

答えて

0

私はそれを行う方法を見つけました:

string _Path = Path.GetFullPath(mPath); 
      Uri path = new Uri(_Path); 
      string indexingPath = path.AbsoluteUri; 
      CSearchManager csm = new CSearchManager(); 
      CSearchCrawlScopeManager manager = csm.GetCatalog("SystemIndex").GetCrawlScopeManager(); 

      if (manager.IncludedInCrawlScope(indexingPath) == 0) 
      { 
       manager.AddUserScopeRule(indexingPath, 1, 1, 0); 
       //add files and folders to content index 
       DirectoryInfo dinfos = new DirectoryInfo(_Path); 
       var targetFiles = dinfos.EnumerateFiles("*.txt"); 
       File.SetAttributes(medicalDicPath, (File.GetAttributes(_Path) & ~FileAttributes.NotContentIndexed)); 
       Parallel.ForEach(targetFiles, targetFile => { File.SetAttributes(targetFile.FullName, (File.GetAttributes(targetFile.FullName) & ~FileAttributes.NotContentIndexed)); }); 
       manager.SaveAll(); 
      } 
関連する問題