You must Sign In to post a response.
  • Category: .NET

    Search file in Directory using partial name in C#

    I need to search file in directory using partial name.

    Ex:

    Directory : c:\Path
    Filename : Error_15623-89562-84562_response.xml
    Partial file name: 15623-89562-84562
    I have tried below.

    Directory.GetFiles("c:\Path", "*15623-89562-84562*.xml", SearchOption.AllDirectories).
    But it didn't work

    Sample file names are :

    Error_15623-89562-84562-12563.xml
    15623-89562-84562_Response.xml
    Duplicate_15623-89562-84562_Response.xml

    Note: Directory contains thousands of files.
  • #769310
    I try your code. But it is working for me. Share your screenshot of folder structure.


  • Sign In to post your comments