2016-04-15 01:02:26 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Reflection.PortableExecutable;
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.Build
|
|
|
|
{
|
2016-04-15 17:31:17 +00:00
|
|
|
public static class PEUtils
|
2016-04-15 01:02:26 +00:00
|
|
|
{
|
|
|
|
public static bool HasMetadata(string pathToFile)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (var inStream = File.OpenRead(pathToFile))
|
|
|
|
{
|
|
|
|
using (var peReader = new PEReader(inStream))
|
|
|
|
{
|
|
|
|
return peReader.HasMetadata;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (BadImageFormatException) { }
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|