确定任何文件的格式 [英] determine format of any file

查看:68
本文介绍了确定任何文件的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道一种通过检查文件扩展名来检测文件格式的方法..
但是我想在不检查扩展名的情况下检测格式Bcoz用户有时可以将媒体文件的扩展名更改为图像文件,因此在这种情况下,我应该能够知道哪个文件是媒体文件,哪个不是.

提前发短信

I know 1 method to detect format of file by checking file extension..
But i want to detect format without checking extension Bcoz sometime user can change extension of say media file to image file, so in that case i should able to knw which file is media file and which is not.

Thnks in advance

推荐答案

最好的建议可能是:忘记它.

可能的文件格式数量仅受已编写的应用程序数量的限制-识别每种格式都是徒劳的,几乎是不可能的任务.

如果您正在寻找特定的文件格式-也许是MP3或AVI-那么您可以查看单个文件格式并将其与文件数据进行比较,但是坦率地说,即使那样也很浪费时间.许多文件格式在文件的开头确实具有签名",但是从仅MP3文件可以以"MP3"开始的意义上来说,它们并不是唯一的,而其他文件格式也可以(并且可能)这样做. (实际上,MP3文件也不是)
Probably the best advice is: forget it.

The number of possible file formats is limited only by teh number of applications that have been written - identifying each of them is a futile and pretty much impossible task.

If you are looking for specific file formats - MP3 or AVI perhaps - then you could look at the individual file format and compare that to the file data, but frankly even that is pretty much a waste of time. Many file formats do have a "signature" at the start of the file, but these are not unique in the sense that only MP3 files can ever start with "MP3" - other can, and (probably) do. (And in fact MP3 files don''t anyway)


您需要自己动手. :)但是,有几件事可以帮助您:

1 .net中的.FileInfo类提供了大量有关该类的信息.根据该信息,您可以(根据您的理解)将文件分类为不同的类别.

2.所有Windows文件夹中都存在thumb.db文件,该文件可以使信息保存文件.您可以阅读这些文件并获取详细信息.

以下网址可以帮助您...了解abt thumb.db

Thumb.db
you need to do it your self. :) but yes there are few things which can help you :

1 .FileInfo class in .net provides alot of information about the class. Depending upon that info you can classify (by your understanding) files into different category.

2. There are thumb.db file present in all windows folder, that keep information baout the files. you can read those file and get the details.

the following url can help you ... to understand abt thumb.db

Thumb.db


这篇关于确定任何文件的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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