我正在使用以下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();