0

подскажите,как правильно получить имя производителя исполняемого файла из свойств файла, пробую использовать вот такое решение Тут, но почему то я вижу только заголовки свойств но не их значения. Мне нужно получить только строку с указанием компании производителя. Заранее спасибо.Вот мой код, он без концовки, без форыча, потому как не могу достать именно параметры,а вижу только заголовки. Сморю только екзешники

public string GetInfoFile(string pa)
{
    List<KeyValuePair<int, string>> Listss=new List<KeyValuePair<int, string>>();

    var path = pa;
    var dir = Path.GetDirectoryName(path);
    var file = Path.GetFileName(path);

    var shell = new Shell32.Shell();
    var folder = shell.NameSpace(dir);
    var folderItem = folder.ParseName(file);

    var names =
        (from idx in Enumerable.Range(0, short.MaxValue)
            let key = folder.GetDetailsOf(null, idx)
            where !string.IsNullOrEmpty(key)
            select new KeyValuePair<int, string>(idx, key))
        .ToDictionary(p => p.Key, p => p.Value);

    var properties =
        (from idx in names.Keys
            orderby idx
            let value = folder.GetDetailsOf(folderItem, idx)
            where !string.IsNullOrEmpty(value)
         select new KeyValuePair<int, string>(idx, names[idx]))
        .ToDictionary(p => p.Key, p => p.Value);

    foreach (var kvp in properties)
        Listss.Add(kvp.Key, kvp.Value);

    return Listss;
}
2
  • А вы пробовали на разных исполняемых файлах? И покажите ваш код.
    – VladD
    25 авг 2018 в 7:39
  • @VladD добавил код 25 авг 2018 в 7:44

1 ответ 1

5

Вариант - использовать класс FileVersionInfo

using System.Diagnostics;


var fvi = FileVersionInfo.GetVersionInfo(pathToExe);
Console.WriteLine(fvi.CompanyName);
Console.WriteLine(fvi.ProductName);
1

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.