UWP How to cancel a file search
Arsen Kovalchuk
0
Reputation points
I have a code to search for files in a user's selected folder, the file search takes some time and I need to be able to cancel it if the user changes the folder
QueryOptions options = new QueryOptions(CommonFileQuery.OrderByName, filesExtensions) { FolderDepth = FolderDepth.Deep };
StorageFileQueryResult queryresult = folder.CreateFileQueryWithOptions(options);
var files = await queryresult.GetFilesAsync();
I tried to use the CancellationToken token for this, but it doesn't work properly.
var files = await queryResult.GetFilesAsync().AsTask(cancellationTokenSource.Token);
Sign in to answer