dotnet-installer/scripts/dotnet-cli-build/Utils/PEUtils.cs
Sridhar Periyasamy 16dcd770f9 Address PR feedback
- Use the right path separator char for unix.
- Contruct some of the args to crossgen outside the loop.
- Add the null check inside Command.Environment.
2016-04-15 10:31:17 -07:00

27 lines
656 B
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection.PortableExecutable;
namespace Microsoft.DotNet.Cli.Build
{
public static class PEUtils
{
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;
}
}
}