Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //In ASCII representation, 0x5A4D is MZ, the initials of Mark Zbikowski, one of the original architects of MS-DOS.
- static bool CheckIsExecutable(string filePath)
- {
- //There's a #define for this value, named IMAGE_DOS_SIGNATURE.
- var firstBytes = new byte[2];
- using (var fileStream = File.Open(filePath, FileMode.Open))
- {
- fileStream.Read(firstBytes, 0, 2);
- }
- return Encoding.UTF8.GetString(firstBytes) == "MZ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement