把二进制流在页面输出为什么文件名老是显示页面名称?
把二进制流在页面输出为什么文件名老是显示页面名称?
代码如是下:
#region 显示信息二进制流,word 显示页面名称
/// <summary>
/// 显示信息
/// </summary>
public void showData()
{
string ID = Request.QueryString["ID"];
string sql = "select FContent,FName,FullName from Annex where id='" + ID + "'";
DataSet ds = 取得数据;
//try
{
byte[] filec = (byte[])(ds.Tables[0].Rows[0]["FContent"]);
Response.Clear();
string FileName = ds.Tables[0].Rows[0]["FName"].ToString();
string FullName = ds.Tables[0].Rows[0]["FullName"].ToString();
//string FullName = FileName;
string imageType = System.IO.Path.GetExtension(FullName).ToLower();
if (FileName.Length > 16)
{
FullName = FileName.Substring(0, 16) + "" + imageType;
}
FullName = ToHexString(FullName);
if (imageType == ".jpg")
{
ResponseEnd(filec, FullName);
}
if (imageType == ".doc")
{
ContentType = "application/msword";
Response.ContentType = ContentType;
Response.ContentEncoding = System.Text.Encoding.Unicode;
FullName = "dd.doc";
Response.AddHeader("Content-Disposition ", "attachment;filename=" + FullName);
Response.Charset = "GB2312";
Response.OutputStream.Write(filec, 0, filec.Length);
Response.End();
}
}
//catch
{
}
}
#endregion
[解决办法]
好神奇。。。
浏览器可以直接解析二进制流么?
浏览器可以直接打开操作Office文件么。。
[解决办法]
Refer this:
http://www.cnblogs.com/insus/articles/2012733.html