이 코드를 사용하여 문제를 해결하십시오.
string path = AppDomain.CurrentDomain.BaseDirectory.ToString() + "Uploadfile\\" + fileName;
System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] bt = new byte[fs.Length];
fs.Read(bt, 0, (int)fs.Length);
fs.Close();
Response.ContentType = "application/x-unknown/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=\"" + fileName;+ "\"");
try
{
if (bt != null)
{
System.IO.MemoryStream stream1 = new System.IO.MemoryStream(bt, true);
stream1.Write(bt, 0, bt.Length);
Response.BinaryWrite(bt);
//Response.OutputStream.Write(bt, 0, (int)stream1.Length);
Response.Flush();
// Response.End();
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
throw ex;
}
finally
{
Response.End();
}