forked from jeremybytes/SlideShow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageLocator.cs
More file actions
28 lines (25 loc) · 734 Bytes
/
ImageLocator.cs
File metadata and controls
28 lines (25 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.IO;
namespace SlideShow;
public static class ImageLocator
{
public static List<string> GetImagesFromLocation(string folder)
{
var images = new List<string>();
var files = Directory.EnumerateFiles(folder,
"*.*", SearchOption.AllDirectories);
foreach (var file in files)
{
if (IsImage(file))
{
images.Add(file);
}
}
return images;
}
public static readonly List<string> ImageExtensions =
new() { ".JPG", ".JPE", ".BMP", ".GIF", ".PNG" };
private static bool IsImage(string file)
{
return ImageExtensions.Contains(Path.GetExtension(file).ToUpperInvariant());
}
}