【发布时间】:2011-11-30 21:47:28
【问题描述】:
我正在使用下面的 C# 代码将 .doc 文件以 varbinary(max) 的形式保存到 SQL Server 数据库中。
我可以保存文件,但是当我取回文件并想在网页上显示内容时,我的代码正在下载文件,我对如何处理它感到非常困惑。
我正在寻找的确切功能是naukri.com 上传简历并提供预览的方式。我的代码是:
byte[] fileContent = new byte[fuResume.PostedFile.ContentLength];
fuResume.PostedFile.InputStream.Read(fileContent, 0, fuResume.PostedFile.ContentLength);
//lblAppliedMessage.Text = ByteArrayToString(fileContent);
//lblAppliedMessage.Text = BitConverter.ToString(fileContent).Replace("-", string.Empty);
byte[] btYourDoc;
btYourDoc = fileContent;
Response.ContentType = "application/ms-word";
Response.AddHeader("Content-Disposition", "inline;filename=yourfilename.doc");
Response.OutputStream.Write(btYourDoc, 0, fileContent.Length);
Response.BinaryWrite(btYourDoc);
Response.End();
【问题讨论】:
标签: c# asp.net sql-server .doc varbinarymax