C#/Winform
[C#] 폴더에서 이미지 파일만 가져오기
kjun.kr
2020. 6. 2. 00:05
728x90
using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions;
namespace TEST { class Function { public static List<string> GetImageFiles(string directoryPath) { List<string> imageFileList = new List<string>();
foreach (string fileName in Directory.GetFiles(directoryPath)) { if (Regex.IsMatch(fileName, @".jpg|.png|.bmp|.JPG|.PNG|.BMP|.JPEG|.jpeg$")) { imageFileList.Add(fileName); } }
return imageFileList; } } }
|
728x90