原文作者不讓轉載,就發個鏈子這里吧,大家自己過去看,
https://codedefault.com/s/how-do-i-call-directory-getfiles-with-multiple-filters-in-csharp-application/
用作備份,這里簡單說一下思路,就是 Directory.GetFiles.Where 中使用 Lambda 運算式來過濾,
再細節一點,一種在 Where 中 用到 .EndWith,另一種是在 Where 中用到 Regex.IsMatch 的正則運算式,
比如,要過濾出.jpg/.png/.tiff/.bmp/.gif 這些檔案,那么這條正則運算式就是:
"^.+\.(jpg|png|bmp|gif|tiff)$"
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/34.html
標籤:C#
