C
ChristopherABurns
I have a very simple code snippet here:
private void Page_Load(object sender, System.EventArgs e)
{
string filePath =
Server.MapPath("\\Transcriber\\TranscriberTest\\");
string fileName = "Test.Zip";
//FileInfo fi = new FileInfo(filePath + fileName);
FileStream fs = File.Open(filePath + fileName,FileMode.Open);
byte[] fileData = new byte[fs.Length];
fs.Write(fileData,0,(int)fs.Length);
fs.Close();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "application/zip";
HttpContext.Current.Response.AddHeader("Content-disposition",
"attachment; filename=" + fileName);
HttpContext.Current.Response.BinaryWrite(fileData);
//HttpContext.Current.Response.WriteFile(filePath +
fileName,0,(int)fi.Length);
HttpContext.Current.Response.End();
}
<end snippet>
No matter what I tweak, the Zip file (I have tried .MP3, PDF to no
avail as well) is corrupt.
I have tried application/octet-stream and application/x-unkown for the
ContentType.
BinaryWrite, and A straight writefile produce the same results - a
corrupt file.
Anyone feeling charitable out there?
Thanks,
Chris
private void Page_Load(object sender, System.EventArgs e)
{
string filePath =
Server.MapPath("\\Transcriber\\TranscriberTest\\");
string fileName = "Test.Zip";
//FileInfo fi = new FileInfo(filePath + fileName);
FileStream fs = File.Open(filePath + fileName,FileMode.Open);
byte[] fileData = new byte[fs.Length];
fs.Write(fileData,0,(int)fs.Length);
fs.Close();
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "application/zip";
HttpContext.Current.Response.AddHeader("Content-disposition",
"attachment; filename=" + fileName);
HttpContext.Current.Response.BinaryWrite(fileData);
//HttpContext.Current.Response.WriteFile(filePath +
fileName,0,(int)fi.Length);
HttpContext.Current.Response.End();
}
<end snippet>
No matter what I tweak, the Zip file (I have tried .MP3, PDF to no
avail as well) is corrupt.
I have tried application/octet-stream and application/x-unkown for the
ContentType.
BinaryWrite, and A straight writefile produce the same results - a
corrupt file.
Anyone feeling charitable out there?
Thanks,
Chris