I am looping through a directory and copying all files. Right now I am doing string.EndsWith checks for '.jpg' or '.png', etc . .
Is there any more elegant way of determining if a file is an image (any image type) without the hacky check like above?
Check the file for a known header. (Info from link also mentioned in this answer)
The first eight bytes of a PNG file always contain the following (decimal) values: 137 80 78 71 13 10 26 10