How to get multiple files with different extension?
You can't set more search filters, because GetFiles only accepts a single search pattern. Instead, you can call GetFiles with no pattern, and filter the results in code, using Lambda expressions:
using System.Linq;
public YourMethodToStart()
{
FileInfo[] fiels = GetFilesFromFolder(@"C:\1");
}
private FileInfo[] GetFilesFromFolder(string path)
{
string[] extensions = new[] { ".txt", ".zip", ".exe" };
DirectoryInfo dInfo = new DirectoryInfo(path);
FileInfo[] files = dInfo.GetFiles()
.Where(f => extensions.Contains(f.Extension.ToLower()))
.ToArray();
return files;
}
ref : https://social.msdn.microsoft.com/Forums/en-US/3e29882f-238e-473b-91c1-8639a51d39cd/get-multiple-files-with-different-extension?forum=csharplanguage
반응형
'게임엔진(GameEngine) > Unity3D' 카테고리의 다른 글
에셋 번들에서 오브젝트를 로드, 언로드(비동기)와 빌드 (0) | 2017.10.19 |
---|---|
Unity 2017 New Features - Sprite atlas, (C#) (0) | 2017.10.18 |
Does DirectoryInfo GetFiles work on Android? => Don't but! (0) | 2017.10.11 |
Reading file from StreamingAssets, Android(StreamingAssets ) (0) | 2017.10.10 |
이미지 로딩 WWW 과 ReadAllBytes 의 성능차이 (0) | 2017.10.09 |