C# How can I test a file is a jpeg?

后端 未结 16 2360
失恋的感觉
失恋的感觉 2020-11-27 03:28

Using C# how can I test a file is a jpeg? Should I check for a .jpg extension?

Thanks

16条回答
  •  情歌与酒
    2020-11-27 03:45

    The code here:

    http://mark.michaelis.net/Blog/RetrievingMetaDataFromJPEGFilesUsingC.aspx

    Shows you how to get the Meta Data. I guess that would throw an exception if your image wasn't a valid JPEG.

提交回复
热议问题