koss koss - 1 year ago 129
C# Question

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

Answer Source

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);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download