Is there a way to get files by generic mime types?
Example: For all the images (“image/png, image/jpeg, …”):
DirectoryInfo.GetFiles("image")
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not easily. DirectoryInfo goes against the file system, which doesn’t inherently contain MIME type information.
You could get all the files by extension using GetFiles() and the extension. You could also hit
HKEY_CLASSES_ROOT\MIME\Database\Content Typeregistry key to turn a list of MIME types into a list of extensions.