koss koss - 5 months ago 57
C# Question

Populate datagridview with FileVersionInfo

I would need to fill a datagrid with the values of versioninfo prellevato by a double foreach.

incorro error:
FileVersionInfo.GetVersionInfo (file)
; (incorrect syntax)

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 };


As BugFinder already pointed you to the documentation of the method FileVersionInfo.GetVersionInfo

It takes only a string as parameter. So you should give it the filename and not the FileInfo

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