vb.net get filename list from wildcard

前端 未结 4 772
野趣味
野趣味 2021-01-27 13:48

I have string say \"c:\\debug\\ *.txt\" In Debug folder there are severeal .txt files , say test1.txt test2.txt test3.txt .

How can I get from this string c:\\debug\\ *.

4条回答
  •  囚心锁ツ
    2021-01-27 14:28

    I use the following code:

    Dim Path As String = "C:\debug"
    Dim Dir As New DirectoryInfo(Path)
    Dim q = (From x In Dir.GetFiles("*.txt", SearchOption.AllDirectories) Select x.FullName).ToArray
    

    You might need to

    Import System.IO
    Import System.Linq
    

    Basically your key for the requirement is SearchOption.AllDirectories which iterates through sub directories as well.

提交回复
热议问题