How to get log files sorted by date in Windows 8.1 app (QueryOptions give me an exception)?

52 views Asked by At

In my windows8.1 app, I have some logs and I want to read them by time, I had code below

List<string> fileFilter = new List<string>();
        fileFilter.Add(".ERROR");
        StorageFolder folder = ApplicationData.Current.LocalFolder;
        QueryOptions queryOptions = new QueryOptions(CommonFileQuery.OrderBySearchRank, fileFilter);
        var query = folder.CreateFileQueryWithOptions(queryOptions);
        IReadOnlyList<StorageFile> filteredFiles = await query.GetFilesAsync();
        if(filteredFiles.Count > 0)
        {
            err = filteredFiles[0].ToString();
        }
        return err;

However, new QueryOptions(CommonFileQuery.OrderBySearchRank, fileFilter); gives an not implemented exception. Is there any solution?

1

There are 1 answers

5
Igor Kulman On

You need to get all the files using GetFilesAsync() on the folder and sort them by yourself.