locked
Get all files RRS feed

  • Question

  • Hello everyone,

    I have multiple file on my apps local storage. I am trying to get all files using extension like .pdf, .png, .xml etc. How to do? Thanks in advance

    Tuesday, August 6, 2013 1:11 PM

Answers

  • You can use QueryOptions to filter the results. See this link for details.

    Example from same link 

    // Set query options with filter and sort order for results
    List<string> fileTypeFilter = new List<string>();
    fileTypeFilter.Add(".pdf");
    fileTypeFilter.Add(".png");
    fileTypeFilter.Add(".xml");
    var queryOptions = new QueryOptions(CommonFileQuery.OrderByName, fileTypeFilter);
    
    // Create query and retrieve files
    var query = KnownFolders.PicturesLibrary.CreateFileQueryWithOptions(queryOptions); // It could be any StorageFolder instead of PicturesLibrary
    IReadOnlyList<StorageFile> fileList = await query.GetFilesAsync();
    // Process results
    foreach (StorageFile file in fileList)
    {
        // Process file
    }
    


    Thanks,
    Sachin
    My Samples

    • Proposed as answer by jrboddie Tuesday, August 6, 2013 1:30 PM
    • Marked as answer by Khant Nipun Wednesday, August 7, 2013 4:56 AM
    Tuesday, August 6, 2013 1:23 PM