locked
How to find file in directory and subdirectories

    Question

  • How can I do something like the following in a Windows Store App in order to recursively search a directory and locate a file based on part of its filename?


    var matchingFiles = Directory.EnumerateFiles(sourcePath, "filename.*", SearchOption.AllDirectories)

    Monday, June 16, 2014 10:42 PM

Answers

  • Hi Stergiosls,

    Why not try something like CreateFileQuery() | createFileQuery() method  with Windows.Storage.Search should be fine. If you are query for the file in the installation folder or app data folder you could use FindFirstFileEx() which is much more faster.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, June 17, 2014 1:29 AM
    Moderator
  • See Quickstart: Accessing files programmatically . As Jamles says, a query (I think that's the second demo in the quickstart) will probably be the best way.
    Tuesday, June 17, 2014 4:13 AM
    Owner

All replies

  • Hi Stergiosls,

    Why not try something like CreateFileQuery() | createFileQuery() method  with Windows.Storage.Search should be fine. If you are query for the file in the installation folder or app data folder you could use FindFirstFileEx() which is much more faster.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, June 17, 2014 1:29 AM
    Moderator
  • See Quickstart: Accessing files programmatically . As Jamles says, a query (I think that's the second demo in the quickstart) will probably be the best way.
    Tuesday, June 17, 2014 4:13 AM
    Owner