November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
I get the error on this line "UnifiedSearchHitCollection searchResult = directory.Search(query);"
Here's the correct sample code:
int userId = 100;
string virtualDir = "/Global/UserPetImages";
UnifiedDirectory directory = HostingEnvironment.VirtualPathProvider.GetDirectory(virtualDir) as UnifiedDirectory;
string fileNamePattern = string.Format("User{0}_PetImage", userId);
UnifiedSearchQuery query = new UnifiedSearchQuery();
query.FileNamePattern = fileNamePattern;
UnifiedSearchHitCollection searchResult = directory.Search(query);
Manually searching in FileManager yields same result
Number of hits: 0 | |
VirtualPathProvider 'SiteGlobalFiles', Search Error: D:\MySite\VPP\Global\index not a directory |
It's all good now. I manually needed to add an entry in the EPiServer.IndexingService.exe.config file located at C:\Program Files (x86)\EPiServer\Shared\Services\Indexing Service\
int userId = 100;
string virtualDir = "/Global/UserPetImages";
UnifiedDirectory directory = HostingEnvironment.VirtualPathProvider.GetDirectory(virtualDir) as UnifiedDirectory;
string fileNamePattern = string.Format("User{0}_PetImage", userId);
UnifiedSearchHitCollection searchResult = directory.Search(query);
On the sample code above, I get an error D:\MySite\VPP\Global\index not a directory
I can assure you that the UnifiedDirectory is getting the right one and I could even call directory.GetFiles() and retrieve correct results.
Would you know where \Global\index came from?