基本信息
源码名称:C# 文件信息查看器(实现了拖放文件并查看文件信息)
源码大小:0.01M
文件格式:.zip
开发语言:C#
更新时间:2015-03-14
   源码介绍
可以查看 文件的版本、公司、




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace mgen_simglefileinfo
{
    class FileVersionHelper
    {
        static Dictionary<string, string> names;
        static FileVersionHelper()
        {
            names = new Dictionary<string, string>()
            {
                {"注释", "Comments"},
                {"公司名称", "CompanyName"},
                {"文件名称", "FileName"},
                {"文件版本", "FileVersion"},
                {"内部名称", "InternalName"},
                {"调试版本", "IsDebug"},
                {"补丁版本", "IsPatched"},
                {"语言", "Language"},
                {"版权", "LegalCopyright"},
                {"商标", "LegalTrademarks"},
                {"原始文件名称", "OriginalFilename"},
                {"产品名称", "ProductName"},
                {"产品版本", "ProductVersion"}
            };
        }

        public static Tuple<string, object>[] GetInfo(string file)
        {
            var info = FileVersionInfo.GetVersionInfo(file);
            return names.Select(n => new Tuple<string, object>(
                n.Key,
                typeof(FileVersionInfo).GetProperty(n.Value).GetValue(info, null) ?? (object)"无")).ToArray();
        }
    }
}