示例#1
0
        private static void AssertCanUseImage(ref string path)
        {
            path = path.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
            var expanded = System.Environment.ExpandEnvironmentVariables(path);

            if (!PathUtil.IsFullPath(expanded))
            {
                throw new ApiArgumentException("image");
            }
            if (!File.Exists(expanded))
            {
                throw new NotFoundException("image");
            }

            var peInfo = new PeInfo(expanded);

            if (!peInfo.IsValid)
            {
                throw new ApiArgumentException("image");
            }
        }
        private static bool Is32Bit(string filePath)
        {
            var peInfo = new PeInfo(Environment.ExpandEnvironmentVariables(filePath));

            return(peInfo.Machine == ImageFileMachine.I386);
        }