私は教育ドメイン用のWebサイトを開発しています。 SQL Server 2008でFilestream
を使用してバイナリ形式の文書(MS Wordまたはテキストファイル)を保存しますが、テキストボックスで文書を取得できません。次のようにSQLサーバーのfilestreamとaspxのC#
私のコードは次のとおりです。
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);
にエラーが発生します。
助けてください!
SQL Serverで使用されている.MDFファイルでファイルを開こうとしていますか? –
「読者」には何が含まれていますか?あなたはそこで何の価値観を得ていますか? –
提供されている両方のコードスニペットに違いはありません! – Cerebrus