C# 如何一键获取所有文件属性,包括作者、标题、mp3标签等
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/88181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get all file attributes including author, title, mp3 tags, etc, in one sweep
提问by Notitze
I would like to write all meta data (including advanced summary properties) for my files in a windows folder to a csv file. Is there a way to collect all the attributes? I see mp3 files have a different set of attributes compared to jpg files. (c#)
我想将 windows 文件夹中文件的所有元数据(包括高级摘要属性)写入 csv 文件。有没有办法收集所有属性?我看到 mp3 文件与 jpg 文件相比具有一组不同的属性。(C#)
This can also be a script (vb, perl)
这也可以是脚本(vb、perl)
Update: by looking at libextractor (thank you) I can see this can be achieved by writing different plugins for different type of files. I gather this meta data is not a simple collection...
更新:通过查看 libextractor(谢谢)我可以看到这可以通过为不同类型的文件编写不同的插件来实现。我收集的这个元数据不是一个简单的集合...
回答by TobiX
In a library? Try libextractorif your software is GPL.
在图书馆?如果您的软件是 GPL,请尝试libextractor。
回答by torial
If you can cope w/ VB.Net: http://www.codeproject.com/KB/vb/mp3id3v1.aspx
如果你能应付瓦特/ VB.Net:http://www.codeproject.com/KB/vb/mp3id3v1.aspx
If you can cope w/ C++/.Net: http://www.codeproject.com/KB/audio-video/mp3fileinfo.aspx
如果你能应付 C++/.Net:http: //www.codeproject.com/KB/audio-video/mp3fileinfo.aspx
For either (assuming the C++) is compiled to .Net, you can use Reflector to disassemble the binary and convert it to C#. Check w/ the respective authors about their licenses first (usually Code Project articles are under an open license like CPOL).
对于任一(假设 C++)编译为 .Net,您可以使用 Reflector 反汇编二进制文件并将其转换为 C#。首先与各自的作者核对他们的许可证(通常代码项目文章是在像 CPOL 这样的开放许可证下)。
回答by EBGreen
Ok, after the clarification edits, I would suggest looking at the introspection available in .Net. I will warn you however that I think you will get more satisfying results if you forgo introspection and define the specific properties that you want for the file types that you expect to see.
好的,在澄清编辑之后,我建议查看 .Net 中可用的内省。但是,我会警告您,如果您放弃内省并为您希望看到的文件类型定义所需的特定属性,我认为您将获得更令人满意的结果。
Since scripting is valid, then if this were my problem to solve I would use Powershell since the .net introspection is baked in.
由于脚本是有效的,那么如果这是我要解决的问题,我会使用 Powershell,因为 .net 内省已内置。
回答by Brad Gilbert
It may not be worth it to add all of the data from a jpeg file (exif data). I would hand pick what attributes I wanted from those files.
从 jpeg 文件(exif 数据)添加所有数据可能不值得。我会从这些文件中手动选择我想要的属性。