我正在开发一个教育领域的网站。我想Filestream
在 SQL Server 2008 中使用二进制格式将文档(MS Word 或文本文件)存储在数据库中。但我无法在文本框中检索文档。
我的代码如下:
string path = reader.GetString(0);
SqlFileStream stream1 = new SqlFileStream(path, (byte[])reader.GetValue(1), FileAccess.Read, FileOptions.SequentialScan, 0);
StreamReader fs = new StreamReader(stream1);
fs = File.OpenText(path);
string s = fs.ReadToEnd();
txtInput.Text = s;
//lblStatus.Text = "File Succesfully Read!"
fs.Close();
此代码仅适用于存储在文件系统而不是数据库中的文档。所以我尝试了以下代码:
string path = reader.GetString(0);
SqlFileStream stream1 = new SqlFileStream(path, (byte[])reader.GetValue(1), FileAccess.Read, FileOptions.SequentialScan, 0);
StreamReader fs = new StreamReader(stream1);
fs = File.OpenText(path);
string s = fs.ReadToEnd();
txtInput.Text = s;
//lblStatus.Text = "File Succesfully Read!"
fs.Close();
在此代码中,它在线给出错误fs = File.OpenText(path);
为“拒绝访问路径”。
请帮忙!