Reputation: 5114
I need to list all of the images in a folder using C#.
I searched Stack Overflow and found some threads talking about it, but the questions were covering PHP. I need to do this with C#.
Upvotes: 3
Views: 14323
Reputation:
DirectoryInfo di = new DirectoryInfo(@"C:\YourImgDir");
FileInfo[] Images = di.GetFiles("*.jpg");
You can substitute whatever image file extensions you so desire.
Upvotes: 6
Reputation: 5325
This is for C#:
string[] files = Directory.GetFiles("Location of Files", "*.jpg"); //.png, bmp, etc.
Upvotes: 5
Reputation: 3891
You can use Directory.GetFiles
to get the filenames of files in a directory:
var files = Directory.GetFiles("directory_path", "*.jpg");
You can change .jpg
for any other file type. The asterisk is a wildcard character.
Upvotes: 2