Last active
August 29, 2015 14:21
-
-
Save sidewinder94/a33f93f29abf83a2e265 to your computer and use it in GitHub Desktop.
List all ClickOnce Applications for a User
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.IO; | |
using System.Text.RegularExpressions; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var fileNameRegEx = new Regex(@"^.*\\", RegexOptions.Compiled); | |
var exes = Directory.EnumerateFiles(@"C:\Users\<username>\AppData\Local\Apps\2.0", "*.exe", | |
SearchOption.AllDirectories); | |
var apps = new Dictionary<String, Tuple<String, Version>>(); | |
foreach (var file in exes) | |
{ | |
var fileName = Path.GetFileName(file); | |
Version v = null; | |
Version.TryParse(FileVersionInfo.GetVersionInfo(file).FileVersion, out v); | |
if (fileName == null || v == null) continue; | |
if (!apps.ContainsKey(fileName)) | |
{ | |
apps.Add(fileName, new Tuple<string, Version>(file, v)); | |
} | |
else if (v > apps[fileName].Item2) | |
{ | |
apps[fileName] = new Tuple<string, Version>(file, v); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment