使用FileVersionInfo填充datagridview

时间:2016-11-09 08:37:25

标签: c# datagridview

我需要用double foreach来填充带有versioninfo prellevato值的数据网格。

  

incorro错误:FileVersionInfo.GetVersionInfo (file); (语法不正确)

DirectoryInfo dir = new DirectoryInfo(@"D:\TEMP\");

foreach (DirectoryInfo folder in dir.GetDirectories())
{
    foreach (FileInfo file in folder.GetFiles())
    {
        FileVersionInfo verInfo = FileVersionInfo.GetVersionInfo(file);
        dataGridView1.ColumnCount = 1;
        dataGridView1.Columns[0].Name = "Version";
        string[] row = new string[] { verInfo.ProductVersion };
        dataGridView1.Rows.Add(row);
    }
}

1 个答案:

答案 0 :(得分:0)

正如BugFinder已经向您指出了方法FileVersionInfo.GetVersionInfo

的文档

只需string作为参数。所以你应该给它文件名,而不是FileInfo

FileVersionInfo verInfo = FileVersionInfo.GetVersionInfo(file.FullName);