Response.AddHeader(“Content-Disposition”) not opening file in IE6

i have found the problem in IE 6 we have to read the content and use buffers and binary write to open file in IE 6,, the code below works fine for me in IE6

FileStream sourceFile = new FileStream(Server.MapPath(@"FileName"), FileMode.Open);
float FileSize;
FileSize = sourceFile.Length;
byte[] getContent = new byte[(int)FileSize];
sourceFile.Read(getContent, 0, (int)sourceFile.Length);
sourceFile.Close();
Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = true;
Response.ContentType = ReturnExtension(file.Extension.ToLower());
Response.AddHeader("Content-Length", getContent.Length.ToString());
Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName);
Response.BinaryWrite(getContent);
Response.Flush();
Response.End();

Leave a Comment