I am working on ASP.Net page and above code I am using in one acsx control and when ran the VS solution its working fine but when its hosted in IIS, the code is not reading file
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"));
}