Hi SMEs / Team,
if (!IsExeFile(ReadAllBytes(postedFile.FileName))) { extension = System.IO.Path.GetExtension(postedFile.FileName).ToLower(); if (ContentTypeList.Contains(extension) != null || extension != string.Empty) { mimeType = ContentTypeList.Contains(extension).MimeType;
if (mimeType != string.Empty) { maxLength = Framework.Global.ContentTypeList.Contains(extension).Size; uploadFile = true; } } }
private static byte[] SubByteArray(byte[] data, int index, int length) { byte[] result = new byte[length]; Array.Copy(data, index, result, 0, length); return result; } public static bool IsExeFile(byte[] FileContent) { var twoBytes = SubByteArray(FileContent, 0, 2); return ((Encoding.UTF8.GetString(twoBytes) == "MZ") || (Encoding.UTF8.GetString(twoBytes) == "ZM")); }