C# GetFiles
var path = AppDomain.CurrentDomain.BaseDirectory + "Images\\Rooms\\"; // string[] patterns = new[] { "*.jpg", "*.jpeg", "*.jpe", "*.jif", "*.jfif", "*.jfi", "*.webp", "*.gif", "*.png", "*.apng", "*.bmp", "*.dib", "*.tiff", "*.tif", "*.svg", "*.svgz", "*.ico", "*.xbm" }; string[] patterns = new[] { "*.jpg", "*.png" }; string[] files = patterns.SelectMany(pattern => Directory.GetFiles(path, pattern, SearchOption.TopDirectoryOnly)).Distinct().ToArray(); // For.NET 4.0 + var files1 = Directory.EnumerateFiles(path, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".png") || s.EndsWith(".jpg")); // For 2.0, var files2 = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".png") || s.EndsWith(".jpg")); //不支援多種型別同時獲取 FileInfo[] fileInfos = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "Images\\Rooms\\").GetFiles("*.jpg");
相關文章
- 【C#】Learn C# in X minutesC#
- [C#]C#中字串的操作C#字串
- [C#]C#時間日期操作C#
- C#C#
- C# 語言歷史版本特性(C# 1.0到C# 8.0彙總)C#
- C#語言歷史版本特性(C# 1.0到C# 8.0彙總)C#
- C# 9.0 正式釋出了(C# 9.0 on the record)C#
- C# ActivatorC#
- C# on DevCloudC#devCloud
- C#方法C#
- C#特性C#
- C# 物件C#物件
- C# SubstringC#
- C#反射C#反射
- C# FirstOrDefaultC#
- C#教程C#
- C# 打包C#
- C# ViewStateC#View
- c# channelC#
- C# VolatileC#
- C# 概念C#
- C# DbHeplerC#
- 重學c#系列——c#執行原理(二)C#
- C#神器"BlockingCollection"類實現C#神仙操作C#BloCGC
- 【C#開發】C#的協變和逆變C#
- C#閉包C#
- C#初學C#
- C#遞迴C#遞迴
- C#呼叫PythonC#Python
- C#操作jsonC#JSON
- C#方法2C#
- C# 填充ExcelC#Excel
- C# 字串操作C#字串
- C# Lambda MapperC#APP
- C#筆記C#筆記
- C#泛型C#泛型
- C#委託C#
- c# Autofac使用C#