Skip to content

Instantly share code, notes, and snippets.

@borismod
Last active August 29, 2015 14:14
Show Gist options
  • Select an option

  • Save borismod/2b89eae39110a1c507c1 to your computer and use it in GitHub Desktop.

Select an option

Save borismod/2b89eae39110a1c507c1 to your computer and use it in GitHub Desktop.
List files recursively with their max version
using System;
using System.Windows.Forms;
using System.IO;
using System.Linq;
using System.Diagnostics;
class Script
{
static public void Main(string[] args)
{
if (args == null || args.Length < 1 )
{
Console.WriteLine("Specify path to find files" );
return;
}
var directory = args[0];
var filesWithVersions = Directory.EnumerateFiles(directory, "*.*", SearchOption.AllDirectories)
.Select(f => new {FileName = Path.GetFileName(f), Version = FileVersionInfo.GetVersionInfo(f)})
.Where(f => f.Version.ProductVersion != null)
.GroupBy(f => f.FileName)
.Select(g => new {FileName = g.Key, MaxVersion = g.Max(r => r.Version.ProductVersion)})
.ToList();
foreach (var filesWithVersion in filesWithVersions)
{
Console.WriteLine("{0}\t{1}", filesWithVersion.FileName, filesWithVersion.MaxVersion);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment