In C#, how can I know the file type from a byte[]?

后端 未结 10 1257
不思量自难忘°
不思量自难忘° 2020-11-28 08:28

I have a byte array filled from a file uploaded. But, in another part of the code, I need to know this file type uploaded from the byte[] so I can render the correct content

10条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 09:07

    Using the System.Drawing.Image 'RawFormat.Guid' Property you can detect MIME Type of Images.

    but i am not sure how to find other File Types.

    http://www.java2s.com/Code/CSharp/Network/GetImageMimeType.htm

    UPDATE: you may try taking a look on this post

    Using .NET, how can you find the mime type of a file based on the file signature not the extension

提交回复
热议问题