I am developing a website for an educational domain. I want to save a document (MS Word or text file) in a database in binary format using Filestreamin SQL Server 2008. but I can not get the document in a text box.
My code is as follows:
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;
fs.Close();
This code only works for documents that are stored in the File System, and not in the database. So I tried the following code:
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;
fs.Close();
In this code, it gives an error in the line fs = File.OpenText(path);
like "Access denied to path."
Please, help!
madhuri pokharkar
source
share