在 C# 中,如何从字节 [] 中知道文件类型? [英] In C#, how can I know the file type from a byte[]?

查看:33
本文介绍了在 C# 中,如何从字节 [] 中知道文件类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从上传的文件中填充了一个字节数组.但是,在代码的另一部分,我需要知道从 byte[] 上传的这个文件类型,这样我才能将正确的内容类型呈现给浏览器!

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-type to browser!

谢谢!!

推荐答案

不确定,但也许你应该调查一下 幻数.

Not sure, but maybe you should investigate about magic numbers.

更新:阅读它,我认为它不是很可靠.

Update: Reading about it, I don't think it's very reliable though.

这篇关于在 C# 中,如何从字节 [] 中知道文件类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆