Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Checks your iTunes folder for any .ipas that look like Xamarin apps
void Main()
{
var myXamarinApps =
Directory
.EnumerateFiles(Path.Combine(Environment.GetEnvironmentVariable("HOMEPATH"), @"Music\iTunes\iTunes Media\Mobile Applications"), "*.ipa")
.Where(f=> ZipFile.Open(f, ZipArchiveMode.Read)
.GetRawEntries()
.Any(e=> e.FullName.Contains(".monotouch-")));
foreach (var app in myXamarinApps)
Console.WriteLine(Path.GetFileNameWithoutExtension(app));
}
// we need this because some apps contain non-windows-friendly filenames, and ZipArchive.Entries will throw
// http://www.codeproject.com/Tips/1007398/Avoid-Illegal-Characters-in-Path-error-in-ZipArchi
public static class ZipArchiveHelper
{
private static FieldInfo _Entries;
private static MethodInfo _EnsureDirRead;
static ZipArchiveHelper()
{
_Entries= typeof(ZipArchive).GetField("_entries",BindingFlags.NonPublic|BindingFlags.Instance);
_EnsureDirRead = typeof(ZipArchive).GetMethod("EnsureCentralDirectoryRead", BindingFlags.NonPublic | BindingFlags.Instance);
}
public static List<ZipArchiveEntry> GetRawEntries(this ZipArchive archive)
{
try { _EnsureDirRead.Invoke(archive, null); } catch { }
return (List<ZipArchiveEntry>)_Entries.GetValue(archive);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment