确定没有扩展名的文件类型 [英] Determine type of file without extension

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

问题描述

嗨大家好,

我需要帮助,



如何以编程方式确定文件的类型,如Windows文件属性。

例如:文件类型:应用程序,服务或批处理文件等...



请看一下:

http://www.fileswap.com/dl/Bjca9UhkRG/





提前致谢...

Hi Guys,
Please I need help,

How can I programmatically determine the type of the file like windows File Properties.
For example: Type of file: Application, Service or Batch File,etc...

Please take a look:
http://www.fileswap.com/dl/Bjca9UhkRG/


Thanks in advance...

推荐答案

Windows的用途是查看文件扩展名,然后查看注册表以确定它是什么类型的文件,以及应用程序处理它的内容。该信息可以包含内容类型键,用于描述文件类型。



要复制此内容,您必须执行相同操作,或使用SHGetFileInfo:这可能有所帮助: http:// stackoverflow.com/questions/3780028/how-can-i-get-the-description-of-a-file-extension-in-net [ ^ ]
What Windows does there is look at the file extension and then look in the registry to decide what kind of file it is, and what application processes it. That info can include "Content Type" key, which describes the file type.

To duplicate this, you would have to do the same thing, or use the SHGetFileInfo: This may help: http://stackoverflow.com/questions/3780028/how-can-i-get-the-description-of-a-file-extension-in-net[^]

< br>

严格来说,没有扩展这样的东西。这是一些历史问题:在一些旧系统中,文件名称有一个扩展名,它不是名称的一部分。目前,只有名字;并且有一些命名约定不是强制性的,不再影响任何功能。在Windows shell中,这些扩展可用于识别注册表中记录的文件类型,其中规定了可以在Shell级别执行哪些操作,使用什么应用程序,使用什么命令行。



否,如果没有扩展名,则无法识别这些类型。但即使有扩展,也常常是不可能的。没有任何类型的操作系统级通用机制。 扩展的规则不是规则;这是非常松散的机制。相同的扩展可以用于不同的格式,反之亦然,或者扩展不能完全描述类型,如媒体文件的情况。对于应用程序,它可以是一个多步骤的过程。尝试打开文件,应用程序查看文件签名(最开头的一些第一个字节),然后检查文件头,依此类推......没有什么绝对通用的。无论如何,操作系统并不关心它;您可能需要为自己的应用程序开发自己的文件格式,等等...



Windows资源管理器文件名不是资源管理器,因为它看起来像你的图片;它实际上是Explorer.EXE。仔细看。删除愚蠢的文件夹选项选项隐藏已知类型的扩展名。



-SA
Strictly speaking, there is no such thing as "extension". This is some historical casus: in some old systems, there was an "extension" to the name of the file, which wasn't a part of the name. Presently, there is just the name; and there are naming conventions which are not mandatory and no longer effect any functionality. In Windows shell, those "extension" can be used for recognition of the "file types" recorded in the Registry where it is prescribed what operations can be performed at the Shell level for what file, using what application, with what command line.

No, without "extension", you cannot recognize those types. But even with "extension", it is often impossible. There is no any kind of OS-level universal mechanism. The rules for "extensions" are no rules; this is very loose mechanism. The same "extension" can be used for different formats and visa versa, or "extensions" not completely describe the type, as in case of media files. For an application, it can be a multi-step process. The file is attempted to open, the application looks at file signature (some first bytes at the very beginning), then examine "file header", and so on… There is nothing absolutely universal. Anyway, the OS does not care about it; you may need to develop your own file formats for your own applications, and so on…

Windows Explorer file name is not "explorer" as it looks on you picture; it is actually "Explorer.EXE". Look thoroughly. Remove the stupid "Folder Options" option "hide extension of known types".

—SA


这篇关于确定没有扩展名的文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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