varbinary(max)
以下の C# コードを使用して、.doc ファイルを SQL Server データベースに保存しています。
ファイルを保存することはできますが、ファイルを取得して Web ページにコンテンツを表示したい場合、コードがファイルをダウンロードしていて、その処理方法について非常に混乱しています。
私が探している正確な機能は、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();