0
다음 줄 압축 풀기 메일 첨부
content = new StreamReader(new GZipStream(new MemoryStream(a.RawBytes), CompressionMode.Decompress)).ReadToEnd();
InvalidDataException 발생 문제를
을 준다. GZip 스트림에 있는지 확인하십시오.
첨부 파일을 바이트 배열로 변환 할 수 없습니까? 내가 뭘 잘못 했습니까?
Attachment a = (from x in mail.Attachments.OfType<Attachment>()
where !string.IsNullOrEmpty(x.Body) || x.RawBytes != null
select x).FirstOrDefault();
AttachmentName = a.Name;
string AttachmentType = a.Name.Substring(a.Name.Length - 3, 3).ToUpper();
switch (AttachmentType)
{
case "ZIP":
content = new StreamReader(new GZipStream(new MemoryStream(a.RawBytes), CompressionMode.Decompress)).ReadToEnd();
break;
default:
content = new StreamReader(new MemoryStream(a.RawBytes)).ReadToEnd();
break;
}
Gzip 헤더에 포함 된 매직 번호 (파일 형식 서명)가 Gzip 파일이 아닌 것 같습니다. 압축을 풀려고 시도하는 것입니다 ... –
압축하는 동안 실제 바이트 배열에 여분의 바이트를 추가 했습니까? – Rezoan