I tried many solution but code is always checking corrupted file and send true
using (FileStream fileStream = File.OpenRead(path[0]))
{
MemoryStream memStream = new MemoryStream();
memStream.SetLength(fileStream.Length);
fileStream.Read(memStream.GetBuffer(), 0, (int)fileStream.Length);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=myfile.docx");
HttpContext.Current.Response.BinaryWrite(memStream.ToArray());
HttpContext.Current.Response.Flush();
// HttpContext.Current.Response.Close();
HttpContext.Current.Response.End();
}
where path[0] is my docx location..it still read corrupted file and doesnot throw any error..any suggestion plz..
Take a look in this page: How to: Validate a word processing document.
Using the Open XML SDK, you can write a code like this:
But you should also check if the file was really damaged, or your download code isn't ok.