You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Commands: SearchOnDirectoryAsync

The SearchOnDirectoryAsync method returns files located in a given directory and matching specified file name search pattern.


Task<SearchResults> SearchOnDirectoryAsync(string folder, FilesSortOptions options = FilesSortOptions.Default, 
										string fileNameSearchPattern = "", int start = 0, int pageSize = 1024);
folder string The directory path to look for files
options FilesSortOptions It determines the sorting options when returning results
fileNameSearchPattern string The pattern that a file name has to match ('?' any single character, '*' any characters, default: empty string - means that a matching file name is skipped)
start int The number of files that should be skipped
pageSize int The maximum number of files that will be returned

Return Value
Task<SearchResults> A task that represents the asynchronous operation. The task result is SearchResults object which represents results of a specified query.


await store.AsyncFilesCommands.UploadAsync("1.doc", stream);
await store.AsyncFilesCommands.UploadAsync("2.txt", stream);
await store.AsyncFilesCommands.UploadAsync("3.toc", stream);
await store.AsyncFilesCommands.UploadAsync("/backups/1.doc", stream);

SearchResults result = await store
		FilesSortOptions.Name | FilesSortOptions.Desc,
	); // will return 3.toc and 1.doc