在C#中获取ANY扩展文件属性 [英] Getting ANY extended file attribute in C#

查看:102
本文介绍了在C#中获取ANY扩展文件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种方法来在C#中的COM DLL上获取扩展文件属性(特别是产品版本").我在MSDN上找到了一些通过添加"Microsoft Shell控件和自动化" COM参考来使用Shell32的示例,但是文档似乎有些含糊.有没有简单的方法可以做到这一点?

I'm trying to find a way to get an Extended File Attribute (specifically, the "Product Version") on a COM DLL in C#. I found a few examples on MSDN on using the Shell32 from adding the "Microsoft Shell Controls and Automation" COM reference, but the documentation seems somewhat vague. Is there a simple way to do this?

例如:采用C:\ Windows \ Notepad.exe的以下属性:

For example: Take the following properties of C:\Windows\Notepad.exe:

我想以编程方式在C#中获取产品版本"属性.顺便说一下,这可以是任何文件,但是,我只是使用Notepad.exe,因为这是一个通用示例

I want to programatically get the "Product version" attribute in C#. By the way, this could be any file, however, I'm just using Notepad.exe because it's a generic example

推荐答案

或者,您可以使用

Alternatively, you can use the FileVersionInfo class to do that in a single line:

Console.WriteLine(FileVersionInfo.GetVersionInfo(@"C:\Windows\notepad.exe").ProductVersion);

这篇关于在C#中获取ANY扩展文件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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