Method to get all files within folder and subfolders that will return a list

前端 未结 8 1174
别跟我提以往
别跟我提以往 2020-12-04 17:30

I have a method that will iterate through a folder and all of its subfolders and get a list of the file paths. However, I could only figure out how to create it and add the

8条回答
  •  没有蜡笔的小新
    2020-12-04 18:13

    you can use something like this :

    string [] filePaths = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
    

    instead of using "." you can type the name of the file or just the type like "*.txt" also SearchOption.AllDirectories is to search in all subfolders you can change that if you only want one level more about how to use it on here

提交回复
热议问题